Keep It Simple, Stupid | |
PerlMonks |
Re^3: Synchronizing STDERR and STDOUTby xdg (Monsignor) |
on Sep 21, 2006 at 15:58 UTC ( [id://574171]=note: print w/replies, xml ) | Need Help?? |
This fails because the open() makes STDERR go to where STDOUT was going at the time of the open(). The backticks then make STDOUT go to a string, but don't change STDERR (which still goes to the old STDOUT). So don't use backticks. Redirect STDOUT to a file, redirect STDERR to STDOUT and use system() instead.
That still doesn't solve the problem of keeping them in sync because the subprocess still has two buffered handles. The fact that they go to the same place doesn't matter. You need to get the child process to turn off buffering. -xdg Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In Section
Seekers of Perl Wisdom
|
|