in reply to once again: program output and return code
#!/usr/bin/perl # test1.pl use IPC::Open3; $n = "\n"; open( OUTPUT, ">&STDOUT" ) or die "Can't dup STDOUT to OUTPUT: $!$n"; open( OUTERR, ">&STDERR" ) or die "Can't dup STDERR to OUTERR: $!$n"; eval { $pid = open3("<&STDIN", \*OUTPUT, \*OUTERR, 'perl return.pl') ; $val = waitpid(-1,0); # <--- added this line }; $@ && die "ERROR: $@$n"; @results = <OUTPUT>; @errors = <OUTERR>; close OUTPUT; close OUTERR; print "---pid$n"; print $pid . $n; print "---\$?$n"; print $? . $n; # <--- prints exit val print "---results$n"; foreach(@results) { print $_ . $n }; print "---errors$n"; foreach(@errors) { print $_ . $n };
~Particle
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: once again: program output and return code
by barn (Initiate) on Apr 07, 2003 at 17:57 UTC | |
by particle (Vicar) on Apr 18, 2003 at 17:26 UTC | |
Re: Re: once again: program output and return code
by Anonymous Monk on Mar 12, 2002 at 20:05 UTC |