I am not familiar with sylfilter
, and the (somewhat vague) problem description makes me think there is something wrong with feeding it a message on standard input. But if you can make that work, the following is how you examine a program's exit code in Procmail.
:0
* ? sylfilter /dev/stdin
$HOME/Mail/Junk/.
# You should now have the exit code in $? if you want it for further processing
SYLSTATUS=$?
:0
* SYLSTATUS ?? ^^1^^
$HOME/Mail/INBOX/.
# ... etc
The condition succeeds if sylfilter
returns a success (zero) exit code; if it fails, we fall through to subsequent recipes. We save $?
to a named variable so that we can examine its value even if a subsequent recipe resets the system global $?
by invoking some other external program.
By the by, you should not need to hard-code the path to sylfilter
. If it's in a nonstandard location, amend the PATH
at the beginning of your .procmailrc
rather than littering your code with explicit paths to executables. So if it's in /usr/local/really/sf/sylfilter
, you'd put
PATH=/usr/local/really/sf:$PATH
If you need the message in a temporary file, try something like this;
TMP=`mktemp -t sylf.XXXXXXXX`
TRAP='rm -f $TMP'
:0c
$TMP
:0
* ? sylfilter $TMP
$HOME/Mail/Junk/.
# etc as above
The mktemp
command creates a unique temporary file. The TRAP
assignment sets up a command sequence to run when Procmail terminates; this takes care of cleaning out the temporary file when we are done. Because we will be the only writer to this file, we don't care about locking while writing a copy of the message to this file.
For more nitty-gritty syntax details, see also http://www.iki.fi/era/procmail/quickref.html