STDOUT and STDERR redirection fails for forked process



Hi,

I am trying to redirect STDERR to STDOUT and catching the returncode
using the script below.
Currently every error is redirected to the terminal instead of to
STDERR or STDOUT, so i am not able to catch the output if it
originates from a process's STDERR.

Any ideas/suggestions why STDERR is not redirectoed ? (i assume that
the RC is always 0 because of the failed STDERR redirection).

## Issue the command by forking the process and monitoring the
output
if (open STATUS, "$cmdstr 2>&1 |") {
while (<STATUS>) {
$result .= $_ ;
}
close STATUS ;
$rcverror = $? >> 8;
$errmsg = $! ;

}
else {
$errmsg = "Fork failed for \'$cmdstr\'" ;
$rcverror = -2 ;
}

# reset the alarm
alarm(0) ;
$rcvtimeout = 0 ;
} ;

Peter

.



Relevant Pages

  • Re: Process.BeginErrorReadLine and BeginOutputReadLine; buffer not flushed?
    ... script, and redirects the stdout and stderr output from that script ... That means that if the process gets ahead of your reading process at all, the reading process can still wind up in a thread that's happy to keep reading the stream it's working on, while the OS buffers output sent to the other string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Process.BeginErrorReadLine and BeginOutputReadLine; buffer not flushed?
    ... script, and redirects the stdout and stderr output from that script ...  But it's not just the StreamReader that does buffering. ...
    (microsoft.public.dotnet.languages.csharp)
  • Open3 with nonblocking reads
    ... I'm currently trying to execute a script within a script, ... single line should contain if it's STDOUT or STDERR, ... STDOuts were passed to the logfile. ...
    (comp.lang.perl.misc)
  • Re: Filter stdout and stderr Together
    ... I would like to write a script that filters lines from both stdout and ... script with the following syntax: ... stderr as expected, but with particular lines filtered out. ...
    (comp.unix.shell)
  • Re: redirect the output to a file
    ... you have two commands executed in sequence. ... That will cause all output from /make/ to stdout to be sent to ... error messages sent to stderr will only go to the screen. ... Will first redirect stderr to stdout, then send it all to /tee/. ...
    (comp.os.linux.misc)