procmail
[Top] [All Lists]

Re: Running an executable after delivery?

2001-11-03 17:57:54
At 16:00 2001-11-03 -0800, Ross wrote:
This might be an annoying newbie question but is it possible to deliver
to a mailbox and then run an executable?

Yes.  use the COPY flag, and on the second rule, invoke your program:


:0
* some conditions
{
        :0c:
        delivery

        # see 'man procmailrc'
        :0ai
        | launch_some_program
}


I'm doing something with PHP (its the only Unix language I really know
right now). I basically want to do an http request with wget when a new
message is written to a maildir mailbox. I'm trying this sort of thing:

:0c
*
in-testing/
:0:
*
|/mypath/wget -q http://mydomain.com/myscript.php

The log says procmail: Couldn't determine implicit lockfile from
"/mypath/wget".

Basically because it isn't a distinct filename. That * on a line by itself doesn't belong. Get rid of it (in both recipes). For locking on thigs like program execution, try:

:0:my_wget_lockfile

Is there some reason the wget invocation actually needs locking? If so, keep in mind that _this_ scheme won't keep the mailbox from being updated while another invocation of procmail is executing wget on another message, becuase the wget and the mailbox aren't lockfiled with the same lockfile.

The opposite order like this works without error:
:0c
*
|/mypath/wget -q http://mydomain.com/myscript.php

Without emitting a _warning_, because you're not including a trailing ':' on the flags line in this case, which means it isn't using a lockfile. No lockfile, no error about being able to figure out the lockfile name...

A related question: Is it possible to know the name of the new message
file in a maildir mailbox? This would be useful to pass to the script.

I don't use the separate file-per-message format, so I can't answer that question.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

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