At 11:55 +0100 24 Jul 2001, tris(_at_)semireal(_dot_)net(_dot_)dhis(_dot_)org
wrote:
Is there a better way to get a COUNT variable in procmail:
:0 i W: count.lock
{
COUNT = `echo 0\`cat .count\`+1|bc|tee .newcount; \
mv -f .newcount .count`
That's a lot of processes. It should be possible to do it without any
additional processes. The following code is completely untested, but it
should work.
# Get a regional lock
LOCKFILE=count.lock
# Get the old value for COUNT from .count
# This file should have a line like "COUNT=1" (without the quotes)
INCLUDERC=.count
# Increment count using scoring
:0
* $COUNT^0
* 1^0
{ }
COUNT=$=
# Write new count to .count by temporarily redirecting log messages
oldLOG=LOGFILE
LOGFILE=.count
LOG="COUNT=$COUNT
"
LOGFILE=$oldLOG
# Done, so regional lock can go away
LOCKFILE
--
Aaron Schrab aaron(_at_)schrab(_dot_)com http://www.execpc.com/~aarons/
You have the right to remain silent. Anything you say will
be misquoted and used against you.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail