#!/usr/bin/perl # #From root@relay1.mail.uk.psi.net Mon Mar 23 10:54:54 1998 #Date: Mon, 23 Mar 1998 10:51:14 +0000 #From: Super-User #To: ph10@cus.cam.ac.uk #Subject: Contrib - single line mail queue printer in perl # #this simple hacked script produces the queue with one line per message, #to allow you to do the equivalent of # eximq1l | grep 'hotmail.com' | awk '{print $3}' #to extract the message IDs of interesting messages for nefarious purposes. # open ( MQ, "/usr/bin/exim -bp|") or die "can't run the exim command\n"; $state = 0; # simple state machine $recips = 0; while ( ) { $line = $_; chop $line; if ($state == 0) # line read is the sender info { print "$line "; $state = 1; $recips = 0; } else # line read is a recip { if ($line =~ /^$/) # if blank, about to start new mail { $state = 0; print "\n"; } else # append recipient to line { if ($recips > 0) # separate recipients with : { print ':'; } if ($line =~ /^\s+\S\s+(.*)/) { print "$1"; } elsif ($line =~ /^\s+(.*)/) { print "$1"; } ++$recips; } } } # end