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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|