On Wed, Jun 24, 2009 at 05:52:36PM +0800, Jeff Pang wrote:
> 2009/6/23  <pa...@compugenic.com>:
> > I have a script which runs mostly via a cron job and sometimes 
> > interactively.  I would like STDERR to automatically print to both the 
> > console and to a logfile simultaneously.
<snip>

> 
> Hi,
> 
> What causes writting of STDERR?
> If it's due to die and warn, you could redirect them to the customized 
> routines.
> Something like:
> 
> 
> $SIG{__DIE__}=\&log_die;
> $SIG{__WARN__}=\&log_warn;
> 
<snip>

I would but this doesn't properly redirect other errors or warnings as
with system().  I actually created a new post due to lack of response to
this one, the new post is "How to print errors to both STDERR & a
file?".

Basically I think if this was STDOUT, I'd use IO::Tee to merge STDOUT &
a log file and use the new filehandle in a 'select' statement to set it
as the default.  But because this is STDERR I am not sure if this is
possible with Perl.

My goal is to learn something new about Perl and do this the right way,
as this task will be quite common for me.  There are a lot of script I
run via cron jobs which I periodically run manually on the console.

Any suggestions would be appreciated.


Pablo

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to