to make it work with rotating logs add an elsif at the end and do this:
} elsif ($size < $length) {
my $rolled_log = "$logfile.1";
if(-e $rolled_log){
open(LOG, $rolled_log) || die "couldn't open file";
seek (LOG, $length+1,0);
my $data_to_send = "";
while(<LOG>){
$data_to_send .= $_;
}
close LOG;
open LOG, $logfile || die "Couldn't open logfile";
seek (LOG, $length+1,0);
while(<LOG>){
$data_to_send .= $_;
}
my $smtp=Net::SMTP->new($smtpserver,Timeout=>30);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $applicationname Error\n");
$smtp->datasend("\n$data_to_send");
$smtp->dataend();
$smtp->quit();
open FILE, ">$lengthfile" || die "Couldn't open lengthfile for w
+riting";
print FILE $size;
close FILE;
}
--
BigJoeLearn patience, you must.
Young PerlMonk, craves Not these things.
Use the source Luke.