Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Execute command, show realtime output and get exit code

by Eliya (Vicar)
on Nov 01, 2011 at 19:31 UTC ( #935193=note: print w/ replies, xml ) Need Help??


in reply to Execute command, show realtime output and get exit code

...and $? is zero, so I can't get a return code.

close waits for the subprocess and sets $?:

my $pid = open X, '-|', 'echo foo; exit 42' or die $!; my $out = <X>; my $ok = close X; print STDERR "out=$out"; printf STDERR "\$?=%s\n", $? >> 8 unless $ok; __END__ out=foo $?=42

See close for details.


Comment on Re: Execute command, show realtime output and get exit code
Select or Download Code
Re^2: Execute command, show realtime output and get exit code
by afunix (Initiate) on Nov 02, 2011 at 05:32 UTC
    Thanks! You really prevented me from inventing a wheel :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-07-04 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls