procmail
[Top] [All Lists]

Re: Is the matched condition stored in a variable?

1998-12-08 19:23:08
Sree Mokkapati <sree(_at_)ec(_dot_)rockwell(_dot_)com> writes:
Is the matched condition in a recipe stored in some builtin  variable for later
use?

No.


$MATCH will not work because it only stores right hand side of the regex!

Have you considered putting the \/ at the beginning of the regexp, so
that 'everything' is on the right hand side?  Note that to avoid
parsing problems you'll need to put "()" before the "\/", ala:

        :0
        * ()\/blah blah blah....


For example: I have a recipe as below,

:0 c
* ^TO*\(_at_)domain*(_dot_)*
domain-stuff

a) This is a regexp, not a shell globbing pattern.  '*' means "zero or
   more of the previous regexp atom", so that "^TO*" and "domain*"
   almost certainly do not mean what you think they mean.
b) The at-sign (@) is not special in regexps, so there's no need to
   escape it.  This is not perl.
c) Without a \/ token in the regexp, a trailing ".*" is pointless.


I would like to store the matched string into a variable.
For some odd reason, the recipe:

:0
* ^TO(_dot_)+\(_at_)\/.*
{ DOMAIN=$MATCH }

stores the DOMAIN after alias expansion as opposed to the domain to which the 
mail
was ORIGINALly addressed. I guess the ORDER in the "^TO" macro ai'nt helping! 
My
ULTIMATE goal is to GRAB the ORIGINAL address to which the mail was sent into a
$VARIABLE.

It is not clear what you mean by the above.  If you are refering to
messages sent to mailing lists then yes, the ^TO token may match
headers that refer to the mailing list address.  In fact, the "current
address" might not appear in the header at all.  This is not uncommon
with mailing lists.  If you are trying to determine what the "envelope
recipient address" is, as in the address that caused the message to be
delivered to this procmailrc on this machine, then you're probably
trying to implement a virtual domain, and that requires help from the
MTA (Mail Transfer Agent, e.g., sendmail).  Virtual domains done purely
with procmail are *BROKEN* and will get no sympathy from this mailing
list.

If you aren't trying to implement virtual domains, then you'll need to
clarify what you mean by "original address".  Perhaps it would be
clearest if you supplied the headers from a message that is supposed to
have been processed by this .procmailrc?

Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>