procmail
[Top] [All Lists]

RE: return codes

2004-02-27 09:34:14



From: Tom Allison
Sent: Friday, February 27, 2004 2:42 AM
[...]

I'm trying to refine a problem I ran into yesterday on a rule.
I believe that this is essentially correct and it is what I'm using today:

:0 HBW:
* ? razor-check
.razor_spam/

[... first rule, above ...]
Using the first rule, if razor is offline again, it will simply fail to
identify any spam.  However I think I can find the same type of problem
occurring for other scripts and am therefore trying to identify the
return code better.

I was having trouble with the basic process of capturing a return code
and comparing it with constants.  All I'm really doing now is looking to
see if the return code is !=0 or =0.  What I should probably attempt is
to check for 0, 1, or >1 and so on.

As an aside, razor-check works the opposite of spamc/spamassassin, for
example.
Spamc -c will return a status of 0, if the mail is _not_ spam, 1 if it is.
This makes more sense to me 0 = good, 1 = bad.

So, whatever scheme you come up with, you'll need to be careful regarding
the
'polarity' of the return code.


BTW, here are the suggestions from the razor-client documentation:

       To change the "Subject" header if mail is spam:
               :0 Wc
               | razor-check
               :0 Waf
               | formail -i "Subject: Razor Warning: SPAM/UBE/UCE"

       To add a "X-Razor2-Warning" header to spam:
               :0 Wc
               | razor-check
               :0 Waf
               | formail -A "X-Razor2-Warning: SPAM."

       To file spam in a mailbox
               :0 Wc
               | razor-check
               :0 Wa
               /home/foo/Mail/razor-caught

----

That last bit where it files into razor-caught requires a lock, unless
razoc-caught is a directory, and in that case, a trailing '/' would help
the reader.

---

On this recipe,

:0 HBW:
* ? razor-check
.razor_spam/

It looks like you're delivering to a directory, so you shouldn't require
locking,
unless you're just using the locking as a way of serializing razor-check
calls.

Here's an idea for handling non-zero error codes from razor-check:

:0
* ! ? razor-check
{
RC=$?

:0
* -1^0
* $ $RC^0
{   } # Return code is > 1

:0
* $ RC ?? ^^1^^
{   } # Return code is exactly 1


}



_______________________________________________
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>