procmail
[Top] [All Lists]

Again on setting a different exitcode for each mailbox

2007-11-10 10:00:25
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
}

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

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