Jeff Pang <armyw...@gmail.com> wrote:

> On Tue, Apr 20, 2010 at 1:28 PM, Weizhong Dai <weizhong....@gmail.com>
> wrote:
> > Hi all,
> > In my script, I have a system call, and redirect the stderr to a
> file.
> >        #
> >        # open STDERR, ">$workpath\\error_log.txt";
> >        # system "...";
> >        #
> > but I only want the ERROR messages to be logged in the file. Is there
> 
> try this:
> 
> system "command arguments 2>error.txt";

That's exactly the same as re-opening STDERR, so it's not gonna help the OP.

So how to differentiate between warning and error message?

It all depends on the program's output. If the error messages are clearly 
tagged as such, one might try to filter STDERR by using IPC::Open3 to run the 
system command. That'll give the OP a distinct STDERR filehandle which he can 
read and parse, writing the interesting stuff to a logfile.

HTH,
Thomas

Reply via email to