This will work.

open outfile ">>outfile.txt";
open cmdoutput " $command |";
while(<cmdoutput>) {
   print outfile;
}

close cmdoutput;
close outfile

-----Original Message-----
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 12:48 PM
To: Perl Beginners
Subject: output of a command to a file


Hello everyone,

How can I take the output of a command, put into a scalar, and then put it
into a file?  Here's a portion of what I have:
open(FP, ">>$outfile");
my $command = `whois $h | grep 'created on'`;
print "$command";
print FP "$h $command\n";

The above code doesn't work though.  There's nothing in the $command
variable.  The only thing that gets printed to $outfile is $h.

Thanks everyone

Tyler Longren
Captain Jack Communications
[EMAIL PROTECTED]
www.captainjack.com




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to