Hi all,
i am trying to parse my sendmail log into scaler arrays. i have
been semi-successful but am still getting too many errors that i just cant
figure out what i'm missing. i have reread mastering regular
expressions and ch. 7 in learning perl.
the following is an example of one of the log entries that failed:
=================================================================================
[Jul 4 13:55:03 small sendmail[29727]: NAA29721: to=<[EMAIL PROTECTED]>,
delay=00:00:00, xdelay=00:00:00, mailer=uucp-dom, relay=gate, stat=Sent ]
=================================================================================
the following is the regex:
====================================================================================
if ($record =~ /^(...)\s+(\S+) (..):(..):(..) \S+
sendmail.[0-9]+.: (\S+): to=(\S+).*, delay=..:..:.., xdelay=..:..:..,
mailer=\S+, relay=(\S+), stat=\S+ $/)
{
$record =~ s/^(...)\s+(\S+) (..):(..):(..) \S+
sendmail.[0-9]+.: (\S+): to=(\S+).*, delay=..:..:.., xdelay=..:..:..,
mailer=\S+, relay=(\S+), stat=\S+ $/$1 $2 $3 $4 $5 $6 $7 $8/;
($mon, $day, $hour, $min, $sec, $spool, $to, $relay)
= split / /, $record;
(undef, undef, undef, undef, undef, $year) = localtime;
$dateout = timelocal($sec, $min, $hour, $day, &mon2num($mon),
$year);
# get rid of brackets on address
$to =~ s/^<//;
$to =~ s/>$//;
@data = ($type, $dateout, $spool, $to, '', $relay);
}
else
{
syslog('info', "Error: no match, line " . __LINE__ );
return 'ERROR';
====================================================================================
--
- josh
20A8 2FC6 9099 D215 78F4 D005 B9F3 21C4 300C C25E ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [EMAIL PROTECTED] - tel: +972.58.520.636, http://www.tkos.co.il -