in reply to Extracting network information

Simply escaping the dollars in the awk command will do the trick:

chomp($sysip = `ifconfig | grep -i inet | egrep -v "inet6|127.0.0.1" | head -n 1 | awk '{print \$2}'`);

However, I won't be the only one here who recoils at the way this script is constructed. When you have time, it would be a very good idea to rewrite this in a more efficient and robust manner (as an exercise if nothing else).

Replies are listed 'Best First'.
Re^2: Extracting network information
by Kasemodder (Initiate) on Sep 01, 2015 at 18:34 UTC
    Thanks! That did the trick. I'm by no means advocating this as a good way of doing things, but it's a bit of monkey-see monkey-do with the code that was already there (the previous wasn't using awk, but other bash commands), and what I can figure out to do with it. karma++