From: Paul Jakma (paulj at domain alphyra.ie)
Date: Tue 10 Sep 2002 - 16:17:38 IST
On Tue, 10 Sep 2002, kevin lyda wrote:
> in case anyone is curious, paul refuses to learn perl.
sigh.. no i dont, just for general sysadminy type stuff awk does the
job just as well, and chances are good with awk that it'll
decipherable if it's ever revisited. :)
not perl's fault, mine - it ends up as spaghetti in my hands.
oh, did i mention i've got a 500 odd line awk script at home? :)
(quite readable too)
> and as an aside for those of you who haven't tried zsh, lines like
> that are a good reason to try it.
sigh..
you can do the same thing with perl.
> after you have run a command line like that, just try entering the
> command fc to bring up $EDITOR to further edit it.
god, i was going to stop annoying the list with silly awk stuff,
but you just had to provoke me, :) so... ok...
test.awk:
BEGIN {
gotms = 0;
}
$1 ~ /^Content-Type/ {
if ($0 ~ /charset=.*[wW]indows/ )
gotms=1;
}
$1 == "X-MSMail-Priority:" {
gotms=1;
}
$1 == "X-Originating-IP:" {
gotms=1;
}
$1 == "X-MimeOLE:" {
gotms=1
}
$1 ~ /Mailer|User-Agent/ {
known++;
if ($2 == "Microsoft" ||
($2 " " $3) == "Internet Mail" ||
$2 ~ /QUALCOMM|DMailWeb|WebMail/ ||
$5 ~ /^.Win/ )
gotms=1;
}
# end of message headers for this mail, tally up and reset
$1 == "FUNKYFOOBAR:" && $2 == "ENDMSGBOB" {
if (gotms == 1) {
ms++;
}
mails++;
gotms=0;
}
END {
print "\n";
print "\ttotal mails:\t\t\t\t\t" mails;
print "\tof which unknown:\t\t\t\t" (mails-known);
print "\tof which most likely non-Linux:\t\t\t" ms;
print "\toff the cuff percentage of MS using ilugers:\t" (ms/mails*100) "%";
}
which results in:
[paulj at domain florence mail-in]$ cat ilug | formail -c -a "FUNKYFOOBAR:
ENDMSGBOB" -X "" -ds | awk -f /tmp/test.awk
total mails: 1955
of which unknown: 335
of which most likely non-Linux: 593
off the cuff percentage of MS using ilugers: 30.3325%
this one shouldnt count a message more than once even if the messages
matches on multiple 'looks like non-linux' conditions.
> kevin
regards,
-- Paul Jakma Sys Admin Alphyra paulj at domain alphyra.ie Warning: /never/ send email to spam at domain dishone.st or trap at domain dishone.st
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:18:46 GMT