Catch STDERR



Hi,

I am executing exec('some cool command', $stdout, $exitcode);

That is fine. I get what I in the beginning wanted. However, now I need to
catch the STDERR that the command is generating as well. Some of you might
tell me to redirect STDERR to STDOUT, but that is not possible as I need to
use the STDOUT as is to automate a process.

I know I can do fwrite(STDERR, 'Output some error\n');

So could I fread(STDERR, SOMESIZE)?

Is there anyone with experience of best way of doing this? Should I maybe
use proc_open or something similar and then write it to a file, and then
read that file? Hrm, doesn?t make any sense to do that.

Best regards,
Peter Lauri
 
www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free
.



Relevant Pages

  • Re: STDOUT and STDERR redirection fails for forked process
    ... Simply, fork a command using the OPEN instruction, ... redirect STDERR to STDOUT and capture the returncode of the executed ... and the returncode is not captured. ...
    (comp.lang.perl.misc)
  • Re: getting stdout and stderr for system calls on windows
    ... It doesn't separate stderr and stdout, but for what I want it, it's more than enough. ... #You can then access the output and the return value for the command. ... def initialize cmd ...
    (comp.lang.ruby)
  • Re: How can i let shell program within TCL show run log?
    ... You'll find there that>@ means "redirect child's stdout to a Tcl ... and 2>@ the same for child's stderr. ... could be directly ran to display a command output on a text widget (a ...
    (comp.lang.tcl)
  • Re: Copying silently.
    ... so as to ReDirect both StdIn & StdErr for a Command, ... to think that "I've done it" is fit for stdout, ... do it" is fit for stderr. ... for reports on both Failure & Success? ...
    (uk.people.silversurfers)
  • Re: Getting both PID and output from a command
    ... > I'm calling a command from within a python script and I need to be ... > able to both catch the output (stdout and stderr) from it and also ... > I've tried doing the following to grab stderr (I only need stderr, ... I wouldn't trust using a pipe. ...
    (comp.lang.python)