procmail
[Top] [All Lists]

Re: Running an executable after delivery?

2001-11-03 17:39:56
On Sat, Nov 03, 2001 at 04:00:05PM -0800, Ross wrote:
:0c
*
in-testing/
:0:
*
|/mypath/wget -q http://mydomain.com/myscript.php

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

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

Notice what you're doing with locking when you reverse the order: in the first
case, you're NOT locking the mail folder (the first recipe), but you ARE
locking the pipe to a command. In the second case, you are NOT locking the
pipe, but you ARE locking the folder. The second case is correct. (Depending
on what the command to which you are piping does, it is sometimes appropriate
to use a lock there to)

Note that to match on all messages, you need merely omit a condition, rather
than using a "*" wildcard condition. Also, to tie those two actions (delivery
of the message, and firing your wget command) you can either nest them, or use
the A flag.

        :0
        {
                :0c:
                in-testing/

                :0
                |/mypath/wget -q http://mydomain.com/myscript.php
        }

or

        :0c:
        in-testing/

        :0A
        |/mypath/wget -q http://mydomain.com/myscript.php


but its in the wrong order. I want the script to run when I know its
safe to read the new file written in /in-testing/new.

This is what the A flag is for. This tells a recipe to run ONLY if the
immediatly preceding recipe on the same nesting block level was successful.

Another option is the use of $TRAP.

        TRAP='/mypath/wget -q http://mydomain.com/myscript.php'

        :0:
        in-testing

However, I suspect using A is probably safer, when you want to be sure
delivery was successful before attmepting to run your php script.

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.

$LASTFOLDER will contain this information.

-- 
Andrew Edelstein        -       andrew(_at_)pure-chaos(_dot_)com
http://andrew.pure-chaos.com

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