Rewriting a shell script

From: Scott Mebberson <scott_at_scottmebberson.com>
Date: Mon, 30 Nov 2015 11:34:56 +1030

Hi,

I'm rewriting a shell script into execline, and I'm running into a few
issues. I've used execline before, but not very much. I'm not that skilled
at bash either.

This script (runs within the s6-overlay environment):

#!/usr/bin/with-contenv sh

# Bind to the external (LAN) IP
BIND=`getent hosts ${HOSTNAME} | awk '{print $1}'`

exec s6-setuidgid consul consul agent -config-dir /etc/consul.d/bootstrap
-bind ${BIND};

This is my execline script so far:

#!/usr/bin/execlineb -P

# load in the container environment
/usr/bin/s6-envdir -fn -- /var/run/s6/container_environment

importas -u HOSTNAME HOSTNAME
backtick -in BIND {
    pipeline { getent hosts ${HOSTNAME} }
    awk '{print $1}'
}
import -u BIND

It's dying at the awk line with:

awk: cmd. line:1: Unexpected token
withstdinas: fatal: child process exited non-zero

I know the getent hosts part works, because if I remove the awk line, the
BIND variable has the content I would expect.

Sorry for the noob question. But how can I pass the value to awk without it
complaining?

cheers,
Scott.
Received on Mon Nov 30 2015 - 01:04:56 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC