Hey folks,
I have a set of piped commands that work on the command line, but do not produce output when run within a script.
The command is:
STRNG=$( ip mroute show | tr -d "()," | awk ' {print "/usr/sbin/smcroute -a eth3", $1, $2, "vtun0 vtun1"}' ); echo "$STRNG"`
And the output is:
/usr/sbin/smcroute -a eth3 192.0.1.19 224.1.1.1 vtun0 vtun1
/usr/sbin/smcroute -a eth3 192.0.1.18 224.1.1.1 vtun0 vtun1
However, if I put the very same command line into a script, I get no output from the echo "$STRNG"
command.
What I'm trying to do is execute every line in $STRNG
as a command, but for whatever reason it appears $STRNG
doesn't contain any text in the script, whereas $STRNG
does contain text when run from the command line. I'm sure this is due to limited bash understanding.
Could someone help me with this?