procmail
[Top] [All Lists]

Re: Need help executing a script

1998-04-16 00:38:10
Hernan Sanchez asked,

| I want to execute a script when an e-mail arrives to my accout.  That
| script need some parameters, like the FROM and SUBJECT text of the message
| that arrived... how can I do it ?

| Example:
| :0c:
| | /$HOME/script.pl (parameters)

First, asking for a local lockfile without either naming it or giving proc-
mail something to infer a name from will get you an error.  If you don't need
a local lockfile (if the perl script doesn't modify any files), don't use the
second colon; if you do need one, give it an explicit name after the second
colon.  Procmail can infer its own name for a local lockfile only if the
action is a save-to-folder or if it is a pipe (filtering, delivering, or
delivering a copy) to a command with an append redirector (the ">>" that
tells most shells to add output to the end of an existing file).

Second, "/$HOME" will work but it looks really strange, so I hope you don't
mind that I'm going to use simply "$HOME".

Now to the question (all brackets enclose space and tab or caret, space, and
tab):

 :0
 * conditions if any
 * ^From:[      ]*\/[^  ].*
 { FROM=$MATCH }
 :0A
 * ^Subject:[   ]*\/[^  ].*
 { SUBJECT=$MATCH }
 :0Ac:explicitlockfilename
 | $HOME/script.pl "$FROM" "$SUBJECT"

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