I am trying to have procmail start proftpd when it recieves a mail with a subject string of "Ftp Up" ...
Currently I have this
:0:
* ^From:[email protected]
* ^Subject:.^Ftp()+Up
| /etc/init.d/proftpd start
But this is not working ...
Any pointers?
The regex has a number of weird errors. It's impossible for ^Subject:^Ftp
to match if the Subject:
header is well-formed because Ftp
could never match at beginning of line (well, unless the Subject:
header is immediately followed by a Ftp:
header, which doesn't exist, so that's fairly unlikely to be what you want) and it's unclear what you hope to accomplish by repeating an empty group̣.
Try this instead:
:0 # Notice absence of second colon
* ^From.*mymail@mailserver\.com
* ^Subject:[ ]*Ftp Up$
| sudo /etc/init.d/proftpd start
The whitespace in the square brackets are a space and a tab. The square brackets form a character class and the asterisk repeats the class zero or more times, so this matches arbitrary runs of horizontal whitespace.
I imagine you don't have privileges to start system services from your email account (if you do, change it!) so I added a sudo
as well. You will need to set up appropriate sudo
privileges for your account to run this command without a password.
The gratuituous lock file is a FAQ; see http://porkmail.org/era/procmail/mini-faq.html#locking