Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Assigning output of unix command to a variable

by almut (Canon)
on Dec 23, 2009 at 01:25 UTC ( #814034=note: print w/ replies, xml ) Need Help??


in reply to Assigning output of unix command to a variable

Not really sure why it doesn't get past the '|' (works fine here), but what looks suspicious is the @nodes=(<LIST>); as this reads everything from the second line onwards into an array which you never use in the loop. As a result, there would only be one call to nslookup with $_ holding the first line of the input file. Not sure if that's intended.

Independently of that, you probably want to escape the $2 in the awk command, because backticks do interpolate variables... i.e.

my $nodename=`nslookup $_ | awk -F Name: '{ print \$2 }'`;


Comment on Re: Assigning output of unix command to a variable
Select or Download Code
Re^2: Assigning output of unix command to a variable
by ksermas (Initiate) on Sep 04, 2012 at 18:53 UTC
    Thank you very much. You were right. As soon as I eacaped the '$' it worked perfectly!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://814034]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-10-25 15:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (145 votes), past polls