G
grocery_stocker
"Found in /usr/lib/perl5/5.8.3/pod/perlfaq8.pod
How can I capture STDERR from an external command?
There are three basic ways of running external commands:
system $cmd; # using system()
$output = ‘$cmd‘; # using backticks (‘‘)
open (PIPE, "cmd │"); # using open()
With system(), both STDOUT and STDERR will go the same
place as the script’s STDOUT and STDERR, unless the sysÂ
tem() command redirects them. Backticks and open() read
only the STDOUT of your command."
If open() reads only to STDOUT, Then how when I do something like the
following:
#!/usr/bin/perl -w
open(STDERR, "whore.txt") or die "Cant: $! \n";
I get:
miss_xtc@linux:~/perl> ./op.pl
Cant: No such file or directory
Wouldn't this be writing to STDERR in this case?
How can I capture STDERR from an external command?
There are three basic ways of running external commands:
system $cmd; # using system()
$output = ‘$cmd‘; # using backticks (‘‘)
open (PIPE, "cmd │"); # using open()
With system(), both STDOUT and STDERR will go the same
place as the script’s STDOUT and STDERR, unless the sysÂ
tem() command redirects them. Backticks and open() read
only the STDOUT of your command."
If open() reads only to STDOUT, Then how when I do something like the
following:
#!/usr/bin/perl -w
open(STDERR, "whore.txt") or die "Cant: $! \n";
I get:
miss_xtc@linux:~/perl> ./op.pl
Cant: No such file or directory
Wouldn't this be writing to STDERR in this case?