procmail
[Top] [All Lists]

Re: Evaluating filter exitcodes

2003-11-09 11:05:27
On Sun, 9 Nov 2003, Nils Vogels wrote:

# Handle postmaster and abuse filtering
INCLUDERC=$HOME/Procmail/rc.masters

# Head off to do some white/blacklist comparison
:0 w
| /path/to/filter

Firstly, you probably have a bug there.  If the filter exits with 0,
procmail will consider the message to have been delivered to it.  You
probably really mean one of

:0 wf
| /path/to/filter

Or

:0
* ? /path/to/filter
some_action_here

:0e
{
    EXITCODE=$?
}

#  Continue with sorting for maillinglists/friends etc
INCLUDERC=$HOME/Procmail/rc.subscriptions
INCLUDERC=$HOME/Procmail/rc.friends

What happens is that messages from email addresses in my blacklist are 
being processed by the last two INCLUDERC statements, since the filter 
spits it out on stdout.

If the filter outputs the message, I'll assume you meant :0wf ...

I would like to prevent the last two INCLUDERC's 
from being processed if the EXITCODE != 0 ... Any idea how ?

There are several ways.  Ruud already suggested some; others:

-----
# Put the success conditions first
:0 wf
| /path/to/filter
:0 a
{
 INCLUDERC=$HOME/Procmail/rc.subscriptions
 INCLUDERC=$HOME/Procmail/rc.friends
}
:0 E
{
 EXITCODE=$?
}
-----
# Put the success conditions second
:0 wf
| /path/to/filter
:0 e
{
 EXITCODE=$?
}
:0 E
{   
 INCLUDERC=$HOME/Procmail/rc.subscriptions
 INCLUDERC=$HOME/Procmail/rc.friends
}
-----
# Bail out on failure by unsetting the HOST variable
:0 wf
| /path/to/filter
:0 e
{
 EXITCODE=$?
 HOST
}
INCLUDERC=$HOME/Procmail/rc.subscriptions
INCLUDERC=$HOME/Procmail/rc.friends
-----

I suspect the last is the most like what you want.  Note that you must use
the capital "E"lse on the third recipe in the first two examples, because
the recipe immediately preceding will not have attempted its action.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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