in reply to Reading from STDOUT after Redirecting it.
It might be worth pointing out that re-opening STDOUT within your perl script will only affect stuff printed by that perl script and not the output from programs you spawn from within your perl script using system. They have their own set of file handles which are independant of those in your script.
There are three main ways of capturing the output from a spawned command.
open IN, "cmd args |" or die $!; while( <IN> ) { # do something with each line of input } close IN;
The latter form can be convenient if your command produces a large volume of output but you only need a few or selected lines.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Reading from STDOUT after Redirecting it.
by Thelonius (Priest) on Jul 03, 2003 at 04:58 UTC | |
by sgifford (Prior) on Jul 03, 2003 at 06:20 UTC | |
|
Re: Re: Reading from STDOUT after Redirecting it.
by ccarden (Monk) on Apr 01, 2004 at 21:29 UTC |