procmail
[Top] [All Lists]

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

2002-12-28 15:03:45
Gee thanks for clearing that up!

Unfortunately I have fallen into another problem!

All *seems* to be going well, but I'm not getting my matches :(

DEFAULT=$HOME/mail/inbox
MAILDIR=$HOME/mail

VERBOSE=yes

FROM=`formail -x"From:" | sed -e 's/[   ]*//'
MUSER=`formail -x"From:" | awk -F\< '{print $2}' | sed -e 's/>//'
DOMAIN=`formail -x"From:" | awk -F@ '{print $2}' | sed -e 's/>//'

:0:
* grep -i "${DOMAIN}" .sdfdoms
"sdf'ers"

When I send a mail from poff(_at_)sixbit(_dot_)org:

procmail: [24719] Sat Dec 28 21:44:26 2002
procmail: Executing "formail -x"From:" | sed -e 's/[    ]*//'"
procmail: [24719] Sat Dec 28 21:44:26 2002
procmail: Assigning "FROM=poff(_at_)sixbit(_dot_)org"
procmail: Executing "formail -x"From:" | awk -F\< '{print $2}' | sed -e
's/>//'"
procmail: Assigning "MUSER="
procmail: Executing "formail -x"From:" | awk -F@ '{print $2}' | sed -e
's/>//'"
procmail: Assigning "DOMAIN=sixbit.org"
procmail: No match on "^From:.*majordomo.*"
procmail: Executing " egrep -i "X-List|X-Loop|Precedence: list|List-Id:""
procmail: Non-zero exitcode (1) from " egrep -i "X-List|X-Loop|Precedence:
list|List-Id:""
procmail: No match on " egrep -i "X-List|X-Loop|Precedence:
list|List-Id:""
procmail: No match on "grep -i "$DOMAIN" $MAILDIR/.sdfdoms"
procmail: No match on "grep -i "${FROM}" ".sdf'ers""
procmail: No match on ! "^^^^"
procmail: No match on "grep -i "${FROM}" .school-friends"
procmail: No match on "^From:(_dot_)*(_at_)www\(_dot_)madsci\(_dot_)org"
procmail: Locking "/arpa/ns/p/poff/mail/inbox.lock"
procmail: Assigning "LASTFOLDER=/arpa/ns/p/poff/mail/inbox"
procmail: Opening "/arpa/ns/p/poff/mail/inbox"
procmail: Acquiring kernel-lock
procmail: [24719] Sat Dec 28 21:44:27 2002
procmail: Unlocking "/arpa/ns/p/poff/mail/inbox.lock"
procmail: Notified comsat: "poff(_at_)683414:/arpa/ns/p/poff/mail/inbox"
From poff(_at_)sixbit(_dot_)org  Sat Dec 28 21:44:26 2002
 Subject: test
  Folder: /arpa/ns/p/poff/mail/inbox
317
$

Now I tried manually typing in "grep -i "poff(_at_)sixbit(_dot_)org" .sdfdoms it
works a-ok!

What could be going wrong?

Poff
On Sat, 28 Dec 2002, Professional Software Engineering wrote:

Date: Sat, 28 Dec 2002 12:46:33 -0800
From: Professional Software Engineering 
<PSE-L(_at_)mail(_dot_)professional(_dot_)org>
Reply-To: procmail(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
To: procmail(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
Subject: Re: procmail blues: grepping from /etc/passwd for "SEND" users...

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


poff(_at_)sixbit(_dot_)org
SDF Public Access UNIX System - http://sdf.lonestar.org


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