Hi Monks,
I have a setup script(A) which triggers one of my scripts(B) in which I invoke another script(C) using qx//. The invoked script (C) might take hours for completion and the output of the same is captured in a variable to error checking and parsing the results.
$exec_status = `$cmd 2>&1`;But the problem is that, the setup script(A) actually looks for some messages printed on the console or else it will timeout after waiting for a fixed time. So is there any way I can use in my script (B) which actually does not wait for the script (C)'s completion and print something on the STDOUT periodically like "Waiting for $timout seconds..".
When I use backtick, the script B waits till the script C's completeion which is a very long time. The use of system() works for me which prints to STDOUT, but I cannot parse the output of script C.
So basically I just want to combine the functions of backtic and system() which is not possible as far as I know. If I redirect output to a file how will I monitor that the execution is completed and EOF has reached if I use the below method.
Hope you can pour some insights to this.$timeout=1000; open (FP, "scriptC.pl |") or die 'Error'; while (<FP>) { $output .= $_; sleep 30; $timeout -=30; print 'Waiting for execution to finish'. $timeout; }
In reply to Capturing output of qx// without waiting for completion by ajose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |