procmail
[Top] [All Lists]

Re: procmail blues: half-shod solution...

2002-12-30 12:27:44
At 14:57 2002-12-30 +0100, poff(_at_)sixbit(_dot_)org wrote:
The above works great! No (name) or name <address> or anything! It does
say that it's from the list... but that's not an issue as I want every
list mail into a folder and that works ok.

Funny, I could swear that I stipulated as much when I posted the message which Dallman replied to with his optimized version of the expression. Do you read mail in the order in which it arrives?

^^From = searches the first line (or first instance?) of what comes after
From

\/ something = remove that something?

Procmail notation for starting the MATCH extraction - the assignment of the results of the expression to the MATCH variable.

[^ ] = starts with one space

NO, *does NOT include space*. The "starts with one space" is the literal space which followed "From".

+ = save the rest of this??

One or more occurrences of previous expression unit (that is, one or more non-space characters).

In light of not knowing what the last two expressions were, I'd suggest that you spend some time reading up on regular expressions - both of those are standard regexp components -- it's the first two which are procmail-specific constructs (and are covered in the procmail manpages).

It's just that I've being trying to decode this (I searched and couldnt
find any good tuts on this) so I can do a similar thing and extract the
domain without using awk or formail...

I take it that you didn't actually review my larger message from yesterday, to see the message which Dallman was offering an optimized version of the From_ extraction? Both work just fine.

One invocation of formail isn't going to kill you - and can extract the From: address, which may be preferable for some things. What was killing you was THREE invocations of awk on each and every message.

:0
* ^^From \/[^ ]\/(.*)@+
{ DOMAIN = $MATCH }

which saves domain as off@ for some reason.

You're matching from the beginning of the string (everything up to and including the @ - and the + following it is odd, since there should be only ONE @, without succession).

I was even close enough toget @sixbit.org! I just needed to take off the @
but then I changed it to the above it it's even more horrible!!

Try:

:0
* ^^From [^(_at_)]+@\/[^ ]+
{ DOMAIN = $MATCH }

"^^" means very beginning of the message (since the From_ line - that's the notation we use here for "From " (the From without the colon) as used in unix mailbox format messages, appears at the top of the message - versus "^" which is simply beginning of line), "From " is the header (note the trailing space), "[^(_at_)]+" is an inverted (^) character class ([]) specifying everything except "@", of one or more occurrences (+). "@" is a literal "@". "\/" starts the MATCH operation (please see 'man procmailrc'), "[^ ]+" is an inverted character class specifying everything except a space.

So, mentally walk the expression through the following From line:

>From procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE  Mon Dec 30 06:18:32 
2002

(escaped for your safety and pleasure)

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