afunix has asked for the wisdom of the Perl Monks concerning the following question:
There is just one problem. I need to deliver $? into parent process...my $pid = open(PIPE, '-|'); die "open(): $?" unless (defined $pid); if ($pid) { while (<PIPE>) { print $_; } close(PIPE); } else { die "system(): $!" unless (system($cmd)); die "failed to execute: $!" if ($? == -1); die "signal: ". ($? & 127) if ($? & 127); die "exit code: ". ($? >> 8) if ($? >> 8); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Execute command, show realtime output and get exit code
by Eliya (Vicar) on Nov 01, 2011 at 19:31 UTC | |
by afunix (Initiate) on Nov 02, 2011 at 05:32 UTC |