On 23 Nov 2005 at 11:16, John W. Krahn wrote:
> Dermot Paikkos wrote:
> Hello,
> 
> > Looking at the mail queue on my smtp server I notice the usual amount 
> > of crap. The mailq output is in this format:
> > 
> > 11h  8.5K 1EeoEz-0003t2-00 <>
> >           [EMAIL PROTECTED]
> > 
> > 10h   10K 1EepGl-0004VH-00 <>
> >           [EMAIL PROTECTED]
> > 
> > 11h  8.4K 1EeoUI-0004YR-00 <>
> >           [EMAIL PROTECTED]
> > 
> > In case the formatting doesn't make it, that's a newline after '<>' 
> > and a newlines between each (two-line) record.
> > 
> > I was hoping to do a one-liner that would yield just the message ID. 
> > I tried a few variations but I couldn't get it.
> > 
> > mailq | perl -e 'while (<>) {print $1, "\n" if /([\d+|\w+]-[\d+|\w+]-
> > 00).*porn/m }' 
> > # nothing at all.
> > 
> > mailq | perl -e 'while (<>) {print $1, "\n" if /(\d+|\w+).porn/m }' 
> > # Close but no cigar
> > #phoebe
> > #aimee
> > #yasmin
> > #poppy
> > #charlotte
> > #amy
> > 
> > mailq | perl -e 'while (<>) {print $1, "\n" if /(.*-00).*porn/sm}'
> > # Nothing
> > 
> > I am missing something vital in my regex but I can't spot it. Any 
> > advice?
> 
> Does this do what you want?
> 
> perl -l -00ane'print $F[2] if /porn/'
> 

Thank you both. I should have mentioned that 'This is perl, version 
5.003'. This might explain why I am not getting the results that I 
should from both your replies. After a bit of tweaking I ended up 
with 

mailq | perl -l -00 -ane 'print $F[2]," ",$F[4],"\n" if /porn/'

which gives me 

1Eeiiu-0001fc-00 [EMAIL PROTECTED]
A1Eejg0-0002cz-00 [EMAIL PROTECTED]
A1EelBB-000341-00 [EMAIL PROTECTED]
A1EelLQ-0003S4-00 [EMAIL PROTECTED]
A1EeoEz-0003t2-00 [EMAIL PROTECTED]
A1EepGl-0004VH-00 [EMAIL PROTECTED]

Which is what I want (I'll omit $f[4] later). 

Of course in the long run I need upgrade my perl and install 
spamassassin.

Thanx again.
Dp.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to