procmail
[Top] [All Lists]

Re: procmail recipe problem

1996-09-24 17:05:30
"Dizzy J." <dizzyj(_at_)adrock(_dot_)warez(_dot_)com> writes:
I was hoping someone on this list could give me a hand with setting up a 
recipe.  What I want to do is this:

I want procmail to run a perl script.  If the exit code of the script is 
0 then do nothing (i.e stick the message is INBOX).  If the exit code of 
the script is 1 then stick the message in a different folder.  One catch 
is that I have to have the senders email address as a command line 
parameter for the perl script.

this is what I have so far
FROM=`$FORMAIL -rt -xTo:`
:0 w
| perlscript $FROM
IN.unknown

is there a way to make this work?  it seemas like the from line
doesnt work wither  thanks


Not quite.  You need to run the perl script as a condition.  To quote
the procmailrc(5) manpage:

     There are some special conditions you can use that  are  not
     straight regular expressions.  To select them, the condition
     must start with:

     !    Invert the condition.

     ...

     ?    Use the exitcode of the specified program.


After checking the example on the procmailex(5) manpage, it appears
that the '?' condition is treated as a 'match' if the program has a
return code of 0 (success), so since you want sucess to *not* cause
delivery to IN.unknown to take place, you should use the '!' modifier
to reverse the interpretation:


FROM=`$FORMAIL -rt -xTo:`
:0 w
* ! ? perlscript $FROM
IN.unknown


BTW: you are setting the FORMAIL variable somewhere higher up, no?
procmail doesn't set it for you, and if you have it in your path,
then you might as well just say:

FROM=`formail -rt -XTo:`


I don't understand people's penchants for storing the full pathnames of
programs in variables.  That's what $PATH is for: just add whatever
directory is necessary to your PATH and be done with it.  If you factor
in the trouble and confusion the practice causes ("What, formail was
finally installed in /usr/local/bin?  That's why my .procmailrc broke!"),
you're not saving any time.  Remember: the computer is faster at doing
dumb things like searching for binaries, and it's too literal for me to
trust it with a rope around my neck (or email for that matter).


Philip Guenther

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