#!/usr/bin/perl #senders.cgi use CGI ':standard'; use strict; use warnings; print header(); print start_html(-title =>'Senders', -bgcolor=>'#95B8DB'); print "
"; print "

Senders \n\n\n

"; print "
"; system("sudo grep -E 'Passed CLEAN.* ->.*' /var/log/maillog | grep -v root@ > /tmp/PassedCLEAN.txt"); system("sudo awk '{print \$12}' /tmp/PassedCLEAN.txt > /tmp/PassedCLEAN_1.txt"); system('sed -e "s/<\(.*\@.*\)>/\1/g" /tmp/PassedCLEAN_1.txt > /tmp/PassedCLEAN_2.txt'); my $logfile = '/tmp/PassedCLEAN_2.txt'; open my $fh, '<', $logfile or die "Could not open $logfile : $!"; my %count=(); while (my $line = <$fh>) { foreach my $word (split /\s+/, $line) { ++$count{$word}; #print "$word\n"; #print "
"; #print " \n"; } } print "
"; print "
"; for my $word (sort keys %count) { print "$word $count{$word}\n"; #print "$count{$word}\n"; print "
"; print " \n"; } close $fh; print "
"; print end_html;