|Do you know where your variables are?|
Execute command, show realtime output and get exit codeby afunix (Initiate)
|on Nov 01, 2011 at 12:24 UTC||Need Help??|
afunix has asked for the
wisdom of the Perl Monks concerning the following question:
I need to execute command, display it's output and get exit code.
open(X, '-|', 'cmd') is a good one, but it returns pid in this form and $? is zero, so I can't get a return code.
`cmd` can do everything, but it returns output after command was executed, and I need to display output and put it into log file, just like tee.
There is one more way, the most complicated:
There is just one problem. I need to deliver $? into parent process...
So, dear monks, is there any way to receive command output in a realtime and get it's exit code in some easy way?