-----Original Message-----
From: procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
[mailto:procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE]On Behalf Of
Phillpotts,
James
Sent: Tuesday, August 16, 2005 7:08 AM
I wonder if anyone can help me with the following procmail recipe:
:0
* ^Subject:.*\[MYTAG: *\/.+\]
Above, procmail is "stingy" to the left of \/ and "greedy" to
the right. Therefore the right hand pattern will keep going
until the very last ']' is encountered. Not what you want.
Try:
* ^Subject:.*\[MYTAG: *\/[^\]]+
{
saved = $SHELLMETAS
SHELLMETAS
REALMATCH =`expr "$MATCH" : ' *\(.*\)\].*'`
SHELLMETAS = $saved
Maybe by improving the \/ pattern above, you won't need
this complicated invocation of `expr`?
:0 w
* test ! -w $HOME/$REALMATCH
* ? mailutil create $REALMATCH
:0 w
| /usr/bin/dmail +$REALMATCH
}
Bad syntax above, no delivery recipe after the initial tests.
What I'm trying to with this is:
For all email that contains a preformatted tag, [MYTAG: SomeText], move
the email to the SomeText MBX mail folder. Unfortunately, dmail will not
create a non-existent folder (unlike procmail with unix mail folders),
so I am trying to get procmail to check whether the folder exists first,
and if not, create it before filing the email.
It's doing this last step I'm having problems with - my last try, as you
can see was:
:0 w
* test ! -w $HOME/$REALMATCH
* ? mailutil create $REALMATCH
You forget a leading ? on the invocation of 'test' above. Should read:
* ? test ! - $HOME/$REALMATCH
However, even after this fix, It likely won't work as expected, because
multiple '*' conditions are AND'ed. Thus, above, you're asking that
$REALMATCH is not writeable, and that mailutil create succeeds, and
only then will you invoke dmail.
I'd probably try something like the following:
:0
* ^Subject:.*\[MYTAG: *\/[^\]]+
{
MAILBOX = "$MATCH"
MKMBOX = `test ! -w "$MAILBOX" && mailutil create "$MAILBOX"`
:0 w
| /usr/bin/dmail +"$MAILBOX"
}
Some on this list might not like the use of '&&' above because it
implies the invocation of a shell process.
____________________________________________________________
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