ksermas has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to send the output of a unix command to a variable in Perl? I'm trying to have a while loop read in input, assign it to a variable and then have that variable be the input for the unix command. This is what I have:
#!/usr/bin/perl -w open(LIST, "list"); while(<LIST>) { @nodes=(<LIST>); chomp; my $nodename=`nslookup $_ | awk -F Name: '{ print $2 }'`; print $nodename; } close(LIST);
When I run it, it can't get past the '|' in the nslookup command. Thanks to all who can help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Assigning output of unix command to a variable
by almut (Canon) on Dec 23, 2009 at 01:25 UTC | |
by ksermas (Initiate) on Sep 04, 2012 at 18:53 UTC | |
Re: Assigning output of unix command to a variable
by bichonfrise74 (Vicar) on Dec 23, 2009 at 01:34 UTC | |
Re: Assigning output of unix command to a variable
by ikegami (Patriarch) on Dec 23, 2009 at 01:36 UTC |
Back to
Seekers of Perl Wisdom