procmail
[Top] [All Lists]

Re: using the exitcode of a program as a filter condition

2003-07-14 04:58:21
On Mon, Jul 14, 2003 at 12:45:08PM +0200, Dennis Breithaupt wrote:

I've got a question to the following setup. The following is from (or for 
:)) my global /etc/procmailrc.

:0
* ^X-Spam-Status: Yes.*
? [...]/deletechecker.pl $LOGNAME
   /tmp/Mail.deleted

You're on the right track, but conditions always start with a "*".  So:

  :0
  * ^X-Spam-Status: Yes
  * ? /path/to/deletedhecker.pl $LOGNAME
  /tmp/Mail.deleted

What I wanted is, that if a mail was tagged as spam befor (first condition) 
and a special checking skript returns a defined exitcode, the Mail gets 
deleted (or moved to a trash-box).

Of course, /tmp/Mail.deleted probably isn't a real deleted folder, but
that's something you'll need to figured out based on your own system.

How can I use the exitcode of a script as a condition? What should the 
program give back in case of 'true' and what in case of 'false', for that 
receipe to work?

As with all things shell, an exit value of 0 indicates success, and an
exit value of non-zero indicates failure.  Therefore, a script to check
for the existence of a semaphore in $MAILDIR, might look like:

  #!/usr/bin/perl
  exit(0) if (-r ".deletespam");
  exit(1);

Presumably your deletedchecker.pl script is doing something more complex
than simple shell functions (like checking a database or such), or you'd
just run the test using shell commands:

  :0
  * ^X-Spam-Status: Yes
  * ? test -f .deletespam
  /tmp/Mail.deleted

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


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