procmail
[Top] [All Lists]

Re: Again on setting a different exitcode for each mailbox

2007-11-10 11:11:24
On 10 Nov, M. Fioretti wrote:
Hello,

a few weeks ago, I asked how to put together a procmailrc to be used
only from within a bash script launched from cron, with these
requisites:

- do NOT create extra versions of the processed messages
- return to the calling bash script an exit code which uniquely identifies
  the first procmail recipe which matched on the given message

Unfortunately, I have had time only in the last week to put together
and test all your precious suggestions, but after lots of trials
there's still something I missed, it seems.

With the bash script and procmailrc files below, I _always_ get
PROCMAIL_CHECK equal to 0, no matter which recipe matched, ie I get it
= 0 even on messages cc'ed to mfioretti(_at_)nexaima(_dot_)net or
marco(_at_)rule-project(_dot_)org, while I need it to be (in those cases and 
with
the code below) 52. Where is the error, and what needs to be changed?
Frankly, I'm a bit at loss on what to do next, so any help is really
appreciated.

NOTE: the first time I asked how to do it there several other
approaches that were proposed, but all of them implied delivering
extra copies of messages to be made, or custom log files to be written
or both. If at all possible, I'd rather modify as little as possible
the code below, which avoids, I hope, both complications.

#################################################################

The part of the bash script which needs procmail return value(the mail
messages are in maildir $WAIT_FOLDER):

for FILE in $(find ${WAIT_FOLDER}/new ${WAIT_FOLDER}/cur -type f -mmin +1 
-mmin -4 | grep -v dovecot )
  do
  echo post_processing $FILE
  /usr/bin/procmail -m $RC_FILES/special.rc < ${FILE}
  PROCMAIL_CHECK=$?
  echo "PROCMAIL return value is $PROCMAIL_CHECK"

##################################################

example of recipe in special.rc

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/bin
MAILDIR=/var/mail/archives/base
LOGFILE=/var/log/procmail_logs/PROCMAIL.`/bin/date +%Y.%m`.log
LOGABSTRACT = "all"
VERBOSE     = "on"
DEFAULT     = "/dev/null"

:0hc:relevant.cache$LOCKEXT
* ^CC:.(mfioretti(_at_)nexaima(_dot_)net|marco(_at_)rule-project(_dot_)org)
| formail -D 32768 relevant.cache

:0A:
{
EXITCODE=52
HOST
}

######################################################

Marco,

I didn't follow the first discussion, so I might be missing something.
And I don't have time to test anything, so my guess is from a cursory
reading of the above. That said, I think you probably need an "f"
flag on the first recipe.  As soon as procmail considers the recipe
delivered, processing stops so I don't think it's ever getting to
your "A" block. You and I know that the first recipe didn't actually
deliver the message, but procmail doesn't know that when you pipe to a
program, unless you tell it so with a "f" flag. For procmail, the first
recipe is a delivering recipe. If you look at your log file, I think it
will show that it's never getting to the "A" block.

Don Hammond

-- 
Email address in From: header is valid  * but only for a couple of days *
This is my reluctant response to spammers' unrelenting address harvesting

____________________________________________________________
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