<?xml version="1.0" encoding="windows-1252"?>
<node id="814025" title="Assigning output of unix command to a variable" created="2009-12-22 19:37:02" updated="2009-12-22 19:37:02">
<type id="115">
perlquestion</type>
<author id="813267">
ksermas</author>
<data>
<field name="doctext">
&lt;p&gt; 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: &lt;/p&gt;
&lt;code&gt;
#!/usr/bin/perl -w open(LIST, "list"); 
 while(&lt;LIST&gt;) {

  @nodes=(&lt;LIST&gt;); 
  chomp; 
  my $nodename=`nslookup $_ | awk -F Name: '{ print $2 }'`;  
  print $nodename; } 
  
close(LIST); &lt;/code&gt;
 &lt;p&gt;
When I run it, it can't get past the '|' in the nslookup command. Thanks to all who can help. &lt;/p&gt;</field>
</data>
</node>
