procmail
[Top] [All Lists]

Re: Problems with procmail regexp and <...>

2005-07-21 05:59:11
On Thu, 21 Jul 2005, Dallman Ross wrote:

On Thu, Jul 21, 2005 at 12:09:00PM +0300, Udi Mottelo wrote:

On Wed, 20 Jul 2005, Tad Martin wrote:

I am attempting to process emails via procmail and send certain information
from each email out to a script.  I've had no problems grabbing the subject
or from lines using regexp and setting a variable, then passing the variable
to an external script, but I can't seem to get a regexp that matches a line
formatted as the following:

<anyaddress(_at_)anydomain(_dot_)com>:

This is actually a specific line that I'm trying to grab from a bounced
message sent by the qmail daemon, if anyone cares.

The recipe that I have attempting to do this is:

:0 B
* ^\<\/.*\>:
{
  BOUNCED = "$MATCH"
}
|/scripts/process_rejects.ksh "$BOUNCED"

     And you can do just:

:0 B
* ^\<\/.*\>:
|/scripts/process_rejects.ksh "$MATCH"


Udi, Tad said the attempted regex didn't work.  It's way overbroad,
for one.  It will catch lots of things with a colon.

The OP doesn't want "\<" and "\>" here, because they are
macro tokens and overborad for "<" and ">".  The latter
don't need to be escaped in a procmail regex, with one
notable exception: the first char to the right of a ??
operator or the first char on the line can't be this,
because it has another meaning (size) in that context.
So there it has to be escaped.


        But it works for me(?)  maybe he needs clean the end
        of the matched word because it looks in my log:

procmail: Matched "anyaddress(_at_)anydomain(_dot_)com>:"
                                            ^^

        If you sure it is email address you can do just:

* .*\/[^>]+
* MATCH ?? .*<\/.+

Bye,
  Udi




However, since he wants to capture an address, let's look for
an address, and not just "anything at all."


HOSTPART = [a-z0-9-]
AHOST    = ($HOSTPART[.])*$HOSTPART
DOMPART  = [a-z][a-z]+
FQDN     = $AHOST[.]$DOMPART

SPACE    = ' '
TAB      = '  '
WS       = $SPACE$TAB    # doesn't need quotes!
                         # They're okay to use, though


:0 B hi
* $ ^<\/[^$WS]+(_at_)$FQDN>:$
*   MATCH ?? ^^\/.*[a-z]
| /scripts/process_rejects.ksh $MATCH



Untested, but it looks good to me, absent any typos I'm not seeing.
Note the "hi" flags I added: we don't need to send the body through
the action pipe.

Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail


+++++++++++++++++++++++++++++++++++++++++++
This Mail Was Scanned By Mail-seCure System
at the Tel-Aviv University CC.


---------------------------------------------------------------------------
Udi Mottelo - Unix System Administrator.
Faculty of Engineering - Tel-Aviv University
E-Mail: uuddii(_at_)eng(_dot_)tau(_dot_)ac(_dot_)il    Phone: +972-3-6409446
---------------------------------------------------------------------------

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail