procmail
[Top] [All Lists]

RE: Again on setting a different exitcode for each mailbox

2007-11-11 14:26:00
D E Hammond wrote Saturday, November 10, 2007 7:08 PM:

On 10 Nov, M. Fioretti wrote:

With the bash script and procmailrc files below, I _always_ get
PROCMAIL_CHECK equal to 0, no matter which recipe matched, 


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

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

Note that you've repeated /usr/bin.  Normally it's best
not to set a PATH manually in the rcfile anyway.  The
right path ought be be default with your compile, unless
you have an unusual situation.  My own rcfile setup is very
complex, but I don't set PATH anywhere in it.  The procmail
maintainer (in name, anyway) also recommended not setting
PATH in most cases.

That isn't your problem, though.  It's just a side-issue
I thought I'd mention.

: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

No, he doesn't need the f-flag.  He's using the D switch to formail
to create his cache of Message-IDs.  He's put a c-flag on that recipe,
and the spawned copy falls through to the A.  But he's not changing
the message in any case, so the f-flag would be inappropriate.

I don't think he's saying there's a problem with the A block,
anyway.  I think he's saying his shell script runs that rcfile
but returns a clean exit code always, and that's not what he wants.

What I think he does want is the w or W flag on the first recipe.
See the similar recipe set in "man procmailex":


              :0 Whc: msgid.lock
              | formail -D 8192 msgid.cache

              :0 a:
              duplicates

Note the W flag there.  That's what he needs.

Also, he doesn't want the A-flag on the second recipe, but
rather the a-flag, as in the example above.  The reason is,
the A-flag says, "run me if the above conditions evaluated
as true."  Well, even if the Message-ID is not already in the
cache, the condition was satisfied.  The a-flag, on the
other hand, says "run me if the above *action* completed
successfully."  That's the one he wants.

Also, Marco: you don't want a lockfile on your nested A-recipe.
Recipes that use nested braces don't take lockfiles.  You're not
writing to a file.

Note that even if the above is fixed, I'm not sure the shell
script will show the right result to $?.  You may need to
set the exit code manually if we don't exit inside the nested
brace set.

-- 
dman

____________________________________________________________
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