in reply to Capturing both STDOUT, STDERR and exit status
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; my $cmd = 'ls -la'; my $pid = open3(\*WRITER, \*READER, \*ERROR, $cmd); #if \*ERROR is 0, stderr goes to stdout while( my $output = <READER> ) { print "output->$output"; } while( my $errout = <ERROR> ) { print "err->$errout"; } waitpid( $pid, 0 ) or die "$!\n"; my $retval = $?; print "retval-> $retval\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Capturing both STDOUT, STDERR and exit status
by greenmoss (Novice) on Jun 02, 2010 at 19:03 UTC |