eselement has asked for the wisdom of the Perl Monks concerning the following question:
open(PCC_ERR, "ErrLog.PCC") or die "Cannot open ErrLog.PCC"; #PCC_ERR + is the filehandle. Opens error log use Date::Calc(Today); # needed for calculating 'friendly' dates ($year, $month, $day) = Today; # Go through each line of the error log and only report if a line cont +ains today's date and error codes 3022 or 3186 for $line (<PCC_ERR>) { if ($line =~ /$month-$day-$year/ && $line =~/3022|3186/) { use Net::SMTP; # If the condition is met, send an email with err +or message $smtp = Net::SMTP->new('smtp.server'); # connect to an SMTP se +rver $smtp->mail('email.address'); # use the sender's address h +ere $smtp->to('recipient.address'); # recipient's address $smtp->data(); # Start the email $smtp->datasend("To: recipient.address\n"); $smtp->datasend("From: email.address\n"); $smtp->datasend("\n"); $smtp->datasend("Error Report for $month-$day-$year: Errors Fo +und on Server!\n"); $smtp->dataend(); # Finish sending the mail $smtp->quit; # Close the SMTP connectio +n last; # break loop if error found } } close(PCC_ERR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Date::Calc with an error log
by wind (Priest) on Jul 12, 2007 at 00:41 UTC | |
|
Re: Using Date::Calc with an error log
by chrism01 (Friar) on Jul 12, 2007 at 04:07 UTC | |
|
Re: Using Date::Calc with an error log
by grep (Monsignor) on Jul 12, 2007 at 00:32 UTC |