procmail
[Top] [All Lists]

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

2002-12-28 14:29:37
At 23:05 2002-12-28 +0300, poff(_at_)sixbit(_dot_)org did say:

I really wanted partial matches like, matches a domain:

echo "derek(_at_)sixbit(_dot_)org" | egrep -if .sdfers

This expression has the text within .sdfers being used as the "pattern" and used to match against the text you're passing it (that is, "@sixbit.org" is matching the "body" text of derek(_at_)sixbit(_dot_)org", rather than attempting to use "derek(_at_)sixbit(_dot_)org" to match against "@sixbit.org", which would fail).

In recommending the optimization away from the pipeline process, I made the (incorrect) assumption that you were matching against the constructed .sdfers text file on whole strings, so I overlooked the possibility that you were editing in shorthand for things into this file. In that case, yes, you'd use the pipelined syntax, though you can still make use of the extracted FROM:

:0
* ? echo ${FROM} | grep -if .sdfers
sdfers

Using a the FROM variable extracted within procmail should still be fractionally faster than invoking formail to reprocess the message text to extract it, and you can extract it within procmail ONCE, even though you may be using it to match against lists multiple times (think of running "echo sometext" 10,000 times, versis "formail -x"From:" < messagefile" 10,000 times -- it may not be much, but there's a slight difference).

Is there a better way where I can have, a recipe for matching domains
(this system users can use about 13 different domains) and THEN a separate
recipe for people who aren't on those domains but whom I know...?

Well, you could run two whitelist files if you wanted. Or, you could match domains within procmail (even more efficient than asking grep to check a file, but then you're saddled with maintaining the list of domains within your rcfile, whereas an external text file could be automatically generated or used by other things):

:0:
* ^From:.*@(domain1\.tld|domain2\.tld|domain3\.tld|etc)\>
domain-matched.mbx

I don't know why this new recipe doesn't work whereas the old one appeared
to... something to do with the order of the "regular expression" in
question.

As stated above.

Hmm I getting a *little* less confused... but maybe I'll start it ALL over
again once I've cleared up this grep problewm. And yes, what exactly is
the diff. between grep and egrep?

That's outside the scope of procmail, but egrep is "extended" - it supports an extended set of regular expressions. Try perusing 'man grep' sometime. egrep isn't necessary for the types of expressions you're using though (and if using gnu grep, it defaults to using extended expressions anyway).

---
 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