develooper Front page | perl.beginners | Postings from January 2002

Running commands as variables

Thread Next
From:
David Ulevitch
Date:
January 16, 2002 13:26
Subject:
Running commands as variables
Message ID:
182114127718.20020116152618@everydns.net
Hello beginners,

  I am trying to do this:
  $ns1_in = `/usr/local/sbin/iptables -xvnL |grep 'mrtg' |grep -v 'Chain' |grep 'ns1-in' |awk '{print $2}'`;

  but perl thinks the $2 is for it so it evals it (to '') and then awk
  in return prints the whole line, as opposed to the $2 that I want.

  Escaping the $2 to \$2 didn't work.

  I know this could be done in perl, but I'm always one for the quick
  and dirty CLI way first. ;-)

  Thanks in advance.
  

 
Thanks,
 David Ulevitch                       mailto:davidu@everydns.net
 Founder, EveryDNS.net                http://www.everydns.net     



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About