dattier(_at_)wwa(_dot_)com (David W. Tamkin) writes:
Aaron Turner asked,
| I hope that this makes sense, but what I'm trying to do is set up a script
| that will only run X number of times (before a manual reset) and then stop
| running (IE nothing will give a match).
|
| my psuedo code example:
|
| :0:
| * ^FROM(_dot_)*joe(_dot_)blow(_at_)foo(_dot_)com
| * IF counter not >= 10
| Then INBOX-JOE
| Else /dev/null
Hmm. Interesting. I can't see doing it without a temp file, because how
else can the procmail process delivering one letter communicate with that
delivering another?
It's a small point, but you should lock the counter file before the
read and unlock it after the write. Otherwise you have a race
condition which could allow too many messages through. To do this
you'll want a global lockfile:
SHELL = /bin/sh # if your $SHELL is not Bourne shell for procmail,
# change it at the top of your .procmailrc. csh
# is broken for programming!
:0
* ^From(_dot_)*joe\(_dot_)blow(_at_)foo\(_dot_)com
{
COUNTERFILE = path/to/counter/file
MAXTIMES = 9
# Lock it before the read
LOCKFILE=$COUNTERFILE.lock
:0c:
* $ -`wc -l < $COUNTERFILE 2>&1 || echo 0`^0
* $ $MAXTIMES^0
JOE
:0Ahi # we're already locked via the global lockfile
| echo >> $COUNTERFILE
:0Eh
/dev/null
}
Philip Guenther