tye helped me out with this code a while back on another thread, and i just wanted to finish this up with the working code, so here it is~
#!/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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.