Hi, I've read the perlfaq on capturing stderr from an external
command. However, I cannot seem to get it to capture ALL error
messages. In particular, if the command I'm trying to run externally
fails due to 'command not found' at the shell level, I cannot capture
it with the methods listed.
For instance:
use strict;
use IPC::Open3;
use Symbol qw(gensym);
my $cmd="bogus";
my $pid=open3(gensym, ">&STDERR", \*PH, $cmd );
while( <PH> ) { print $_ }
waitpid( $pid, 0 );
This runs the command "bogus", which fails when I run it by hand as:
-bash: bogus: command not found
however, running the above wrapper perl script gives:
open3: exec of bogus failed at
test.pl line 7
which is too generic of a message to be useful for me.
When I run:
bogus 2> temp.err
cat temp.err
Then it does capture the stderr but I'd like to not have to write temp
files like this, since I am running commands in a pipeline context...
Thanks,
Isaac