[100488] in RedHat Linux List
RE: awk help ? (I think)
daemon@ATHENA.MIT.EDU (Charles Galpin)
Sat Nov 21 00:13:02 1998
Date: Sat, 21 Nov 1998 00:09:35 -0500
From: Charles Galpin <cgalpin@lighthouse-software.com>
To: "Mike A. Lewis, CNE" <redhat-list@redhat.com>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
Try this perl (5) script. I tested this on my maillog which had a slighthly
different output for the "to" line
It is not necessary to be this explicit in some of the matches, but it does
reduce the risk of a false match.
invoke with
#./maillogparse /var/log/maillog > parsed.out
--- start of maillogparse ----
#!/usr/bin/perl -n
if (
/^(\w+\s\d+\s\d+:\d+:\d+)\s+\S+\s+sendmail\[\d+\]:\s+\S+:\s+(from=.*?),\s+(s
ize=.*?),\s+.*?(relay=.*?)$/ ) {
print "$1 $2, $3, $4\n";
}
elsif (
/^(\w+\s\d+\s\d+:\d+:\d+)\s+\S+\s+sendmail\[\d+\]:\s+\S+:\s+(to=.*?),\s+.*?(
delay:.*?),\s+(xdelay:.*?),\s+.*?(relay=.*?),\s+(stat=.*?)$/ ) {
print "$1, $2, $3, $4, $5, $6\n";
}
else # remove this else if you want to ignore all non matching lines
{
print;
}
--- end of maillogparse ----
hth
charles
===== Original Message from "Mike A. Lewis, CNE" <redhat-list@redhat.com> at
11/20/98 4:02 am
>I'm wanting to filter my maillog files to do some troubleshooting. I
>believe that the job can be done with awk, but I'm not familiar with it
>enough to even make a stab at it. Perhaps there is a better way.
>
>Consider the following lines:
>
>Nov 20 00:44:44 mail-rly sendmail[10327]: AAA10327: from=root, size0,
>class=0, pri0130, nrcpts=1, msgid=<199811200844.AAA10327@mail-rly.dprinc.com
><mailto:199811200844.AAA10327@mail-rly.dprinc.com> >, relay=root@localhost
><mailto:relay=root@localhost>
>Nov 20 00:45:16 mail-rly sendmail[10380]: AAA10327: to=cajun@cajuninc.com
><mailto:to=cajun@cajuninc.com> , ctladdr=root (0/0), delay:01:04,
>xdelay:00:32, mailer=esmtp, relay=alligator.cajuninc.com. [204.33.59.15],
>stat=Sent (OK)
>
>
>Keep in mind, there are really only two lines in the above example. What
>I'd like to do is filter the lines such that I would end up with something
>like this:
>
>Nov 20 00:44:44 from=root, size0, relay=root@localhost
><mailto:relay=root@localhost>
>Nov 20 00:45:16 to=cajun@cajuninc.com <mailto:to=cajun@cajuninc.com> ,
>delay:01:04, xdelay:00:32, relay=alligator.cajuninc.com. [204.33.59.15],
>stat=Sent (OK)
>
>Is this possible ? Can someone get me pointed in the right direction ?
>
>TIA,
>Mike
>
>
>--
> PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
> http://www.redhat.com http://archive.redhat.com
> To unsubscribe: mail redhat-list-request@redhat.com with
> "unsubscribe" as the Subject.
-- Charles Galpin <cgalpin@lighthouse-software.com>
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.