in reply to Capturing STDERR to a variable

I just re-read my post and I think it was a bit confusing.
here are some better sorted details:

* The job im running in cron is a perl script (every few minutes).
* I have the cron variable MAILTO (which is the problem - I can't remove it - it's needed for other jobs).
* Im not the only one in the MAILTO list.

what im trying to do is :
1. stop the standard error from being printed so that it won't cause mails to be sent constantly.
2. read the standard error to recover from problems and ignore things that are not problems (like CVS printing things to STDERR for example).

the actual command that im running is :
system("CVS -d :ext:....");
and i would like to get it's STDERR to a variable and (if possible) not through a file.

Replies are listed 'Best First'.
Re^2: Capturing STDERR to a variable
by ikegami (Patriarch) on Nov 02, 2009 at 20:25 UTC

    If you're ok with converting the program's arguments into shell literals and combining STDOUT and STDERR,

    my $output = `CVS -d :ext:.... 2>&1`;

    If not,

    use IPC::Run3 qw( run3 ); run3( [ 'CVS', '-d', ':ext:....' ], \undef, # /dev/null \my $out_fr_chld, \my $err_fr_chld, );