[EXIM] Useful utility? "eximq1l" - one line per queue entry.

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Paul Mansfield
Fecha:  
A: exim-users
Asunto: [EXIM] Useful utility? "eximq1l" - one line per queue entry.

I needed a way of parsing the exim mail queue, so that I had one line per queue
entry.

I thus wrote (threw together?) the attached perl script; the recipients are
strung together with colons to separate (I couldn't think of anything better,
and yes, I did realise that some emails are sent x:y:z@abc)...

Anyway, it's been useful to me, and I'd like to give it to the group in
recognition of the help I've had.

The program has no guarantees or warranties whatsoever of course!

Thanks to everyone...

Paul

---------- Forwarded message ----------
#!/opt/perl/bin/perl


open ( MQ, "/opt/exim/bin/exim -bp|") or die "can't run the exim command\n";


$state = 0;    # simple state machine
$recips = 0;
while ( <MQ> )
{
    $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


--
*** Exim information can be found at http://www.exim.org/ ***