procmail
[Top] [All Lists]

Re: procmail blues: grepping from /etc/passwd for "SEND" users...

2002-12-28 12:16:53
At 17:09 2002-12-28 +0300, poff(_at_)sixbit(_dot_)org wrote:
Thanks very much for your response...

> :0
> * ^From:[       ]*\/[^   ].
> {
>          FROM=$MATCH
> }

I'm horrific with regular expressions and all that sort of thing, I'm
getting the above to match poff(_at_)sixbit(_dot_)org to po or the first 2 
characters
of an address...

That should actually be a .* at the end, not just a dot - typo on my part.

As written, the MATCH portion is any single character that isn't a space or tab, and then optionally, any single character - whereas the proper trailing asterisk will make it "optionally, any number of characters".

> :0
> * ! USER ?? ^^^^
> * ? grep -i "$USER" /etc/passwd
> "sdf'ers"

This works great! Thanks for all your help, I ran grep -i "^$USER:" for
more accuracy.

Ah, yes, in my rush to add the not-null check, I didn't flesh that bit out - wouldn't do to have a user named "bash", or a username which intersected another username (or their longhand name). FTR, by grepping for "^:", you should also be managing to deal with the null user case - there shouldn't be any lines starting with a colon in the /etc/passwd file, although the procmail condition check will completely avoid the invocation of grep, which makes it more efficient when the string is null.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail