procmail
[Top] [All Lists]

Re: Executing external cmds via procmail

2003-05-07 09:40:53
On Tue, May 06, 2003 at 07:58:56AM -0700, Nick Stephens wrote:

:0: /path/to/file.lock
#whatever
{
  :0 bwc
  /path/to/file

  :0
  /path/to/program /path/to/file
}

hrm.. well, I made those changes to the program, and it did indeed go 
farther, but instead of running the program, it appended the body/header 
of the email to the program (/path/to/program).. luckily it was just a 
shellscript, and easy to edit :)

I shouldn't have used your recipe as an example.  ;-)  The recipe that
runs /path/to/program should have an action line that pipes the message
through the command:

  :0: /path/to/file.lock
  #whatever
  {
    :0 bwc
    /path/to/file
  
    :0
    | /path/to/program /path/to/file
  }

Note that procmail will *append* messages to /path/to/file, so make sure
your program can handle that sort of thing, and if it's not already
human-maintained, have something expire old messages from the mailbox.

  BLAH=`echo -n $$. ; date '+%s'`
  :0
  # whatever conditions
  /path/to/file.$BLAH

  :0 A
  * ? /path/to/program /path/to/file.$BLAH
  | rm /path/to/file.$BLAH

That way, if `program` fails, the mail still gets delivered to $DEFAULT,
and multiple messages can be handled through unique filenames.  At the
cost of a subshell, of course, because procmail doesn't have its own way
of generating random numbers.

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