user@domain.com
nil@domain.com
nil@domain.com
lasa@domain.com
lasa@domain.com
ra@anydomain.com
<>
lasa@domain.com
sudhe@domain2.com
char@domain1.com
lasa@domain.com
anu@domain.com
anu@domain.com
####
e.g
nil@domain.com
nil@domain.com
user@domain.com
<>
in this case - nil@domain.com has 2 mails. user@domain.com has 1 mail and <> has 1 mail. I hope U got it.
my below senders.cgi works.
it gives the output as follows to my web page.
##
##
<> 1
anu@domain.com 2
char@domain1.com 1
lasa@domain.com 4
nil@domain.com 2
ra@anydomain.com 1
sudhe@domain2.com 1
user@domain.com 1
##
##
#!/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;