Try to tie STDERR

2002-07-15 Thread Bartlomiej Frackiewicz

Hi,

sorry for my offtopic posting but i haven't found a general perl mailinglist (with 
some traffic).

i want to spy my mod_perl/batch programs, in some case they write an error to STDERR i 
want to send an email to me.

So i wrote Log.pm which has tie functions for handlers, but this doesnt work. it seems 
that perl don´t use print/printf/write functions for writing to STDERR. can someone 
point me to the right way?

Here is a piece of code to understand my idea:

#!/usr/bin/perl -w
use Log;

tie (*STDERR, 'Log');
if (0) {
  $w = 'lala';
}
print $w;
untie (*STDERR);

next we have Log.pm which has currently no email functions

#!/usr/bin/perl -w
package Log;

sub TIEHANDLE {
  my $package = shift;
  print tiehandle called\n;

  return bless {}, $package;
}

sub WRITE {
  my $r = shift;
  print STDOUT write\n;
}

sub PRINT {
  my $r = shift;
  print STDOUT print\n;
}

sub PRINTF {
  my $r = shift;
  print STDOUT printf\n;
}

1;


-- 
BARTLOMIEJ M. FRACKIEWICZ
systementwickler
inity - agentur fuer neue medien gmbh 
birkenstrasse 71  
40233 duesseldorf

telefon: 0211-99199-0
fax: 0211-99199-10
e-mail: [EMAIL PROTECTED]




Re: Try to tie STDERR - Thanks

2002-07-15 Thread Bartlomiej Frackiewicz

Hi Geoff,

funny thing is that i have already the book here, so my teacher was right: we must 
read more books :-)

bye bartlomiej

-Ursprüngliche Nachricht-
Von: Geoffrey Young [mailto:[EMAIL PROTECTED]]
Gesendet: Montag, 15. Juli 2002 17:36
An: Bartlomiej Frackiewicz
Cc: [EMAIL PROTECTED]
Betreff: Re: Try to tie STDERR


try taking a look at recipes 6.10 and 16.6 in the mod_perl developer's 
cookbook - 6.10 ties STDERR just as you do.  16.6 is available online 
and explainswhy just tie()ing STDERR doesn't capture all possible 
sources of writes to the error_log.