Let's examine your action:
:0 ! `script` The meaning of the backticks is "use the output of script as a string here". So if your script outputs [email protected] then the recipe will effectively be equivalent to
:0 ! [email protected] which means to forward the message to [email protected]. The behavior you describe should thus not be surprising at all; Procmail is doing precisely what you are telling it to do.
If you just want to discard the message altogether if your script returns success, you can try this trick:
:0W | script This is basically the same as the formail -D example for suppressing duplicates; if the script returns a success exit status, the message is considered delivered; but since the script doesn't actually deliver it anywhere, it is actually lost. (You will probablyobviously need to invertchange the logic of your script so that its exit code is the inverse of what it is now.)
In case you want the syntax sorted out for you, here is a more general attempt at doing what you seem to think you were doing:
:0 ? ! script ! somewhere which will forward to somewhere if the exit valuecode of script is non-zero;zero (as in success); or possibly
# Capture the output from script in WHERE WHERE=`script` # Also capture its exit code ERR=$? # Forward to $WHERE if $ERR is not zero :0 * ! ERR ?? ^^0^^ ! $WHERE (Several arcane details of uncommon Procmail syntax are present here. The ?? operand examines the value of the named variable; the ^^ anchor matches beginning / end of input string.)
If your script is no more complex than that, you might as well inline it. (Notice the syntax fix with a dash before the i option, and the inversion of the exit status with !):
:0 * ! ? grep -i "$SENDER" /home/foo/scripts/blah/blah2.txt ! somewhere