in reply to Reading from STDOUT after Redirecting it.

Hi there!
You can't use STDOUT as an input because as the name says it's only for output :) Instead open the file to an other FH (eg. FILE)
use strict; use warnings; my $cmd = 'd:\clwhois.exe'; my $ip = '192.168.1.1'; my $file = 'd:\temp\output.txt'; open(STDOUT, ">$file") or die "Can't open $file: $!\n"; # redirect STD +OUT to a temp file system ("$cmd $ip") and warn "Can not execute $cmd: $!\n"; close STDOUT; open(FILE, "$file") or die "Can't open $file: $!\n"; while (<FILE>){ print; } close STDOUT;

Hope that helps and if im mistaken please correct me

atnonis!

Replies are listed 'Best First'.
Re: Re: Reading from STDOUT after Redirecting it.
by Dru (Hermit) on Jul 03, 2003 at 00:02 UTC
    atnonis,

    Thanks for the suggestion. I tried this as well before posting and it does not work. I get the error message print() on closed filehandle STDOUT. I'm going to try the backticks like other's have suggested.