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.
In reply to Assigning output of unix command to a variable by ksermas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |