Greg_R has asked for the wisdom of the Perl Monks concerning the following question:
As you can see, this is a simple print statement. After various attempts I am unable to capture this output. Below is my code snippet intended to capture STDOUT and STDERR and print each line. In my final program I will change this code to wait until I see either the success or failure message.if ($exit_status != 0) { print("-F-Job completed abnormally.(status = $exit_status)\n"); } else { print("-I-Job completed successfully.\n"); }
When I uncomment the print $command line it prints the correct system command. However, the print statements from that system command are not being captured. Am I doing something wrong? Thanks in advance for any tips you can provide. Greg$command = "program_to_run $opt{c} -f test"; # print "$command\n"; open(RUN, "$command 2>&1|"); while (<RUN>) { print "$_\n"; next; } close(RUN); exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unable to capture STDOUT from system command
by almut (Canon) on Jun 29, 2010 at 20:42 UTC | |
|
Re: Unable to capture STDOUT from system command
by BrowserUk (Patriarch) on Jun 29, 2010 at 20:53 UTC | |
by Greg_R (Novice) on Jun 29, 2010 at 22:47 UTC | |
|
Re: Unable to capture STDOUT from system command
by dasgar (Priest) on Jun 30, 2010 at 21:04 UTC | |
|
Re: Unable to capture STDOUT from system command
by Proclus (Beadle) on Jul 01, 2010 at 09:06 UTC |