On Wed, 16 Jan 2002, David Ulevitch wrote: > 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. ;-)
I think if you set your qx symbol to be ', it will turn off interpolation: $ns1_in = qx'<your commands>'; Of course, you will need to escape any single quotes with the comamnd-line string itself. I really do recommend rewriting this in Perl anyway -- it wouldn't be that much more difficult, and would make it more maintainable. I would start with something like: open IPTABLE, '/usr/local/sbin/iptables |' or die "Can't fork: $!\n"; while(<IPTABLE>) { #do stuff with output, which is in $_ } -- Brett http://www.chapelperilous.net/ ------------------------------------------------------------------------ Breadth-first search is the bulldozer of science. -- Randy Goebel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]