the usual solution would be
I'm a bit surprised that nobody called you on rejecting the obvious solution by simple fiat. Why is qx($command 2>&1) unacceptable?
If you run into problems with IPC::Open2, the most portable solution is to redirect your own STDOUT and STDERR to file(s) before using system. If you end up wanting to capture both STDOUT and STDERR but separately, then sending at least one of them to a file is much better than trying to get Perl to drain two file handles (which can easily result in deadlock).
If you need to restore your original STDOUT and STDERR after the command's output has been gathered, then use the example code found in open's documentation for saving and then restoring them.
- tye
In reply to Re: Capturing STDOUT and STDERR of system command, with pure perl? (files)
by tye
in thread Capturing STDOUT and STDERR of system command, with pure perl?
by EvanK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |