<fleet(_at_)teachout(_dot_)org> wrote:
I've come up with the following scheme to count "hits." I have a couple of
questions below the example:
==========================================
LOGFILE=$HOME/spamtest/spamtest.log
DEFAULT=$HOME/spamtest/
VERBOSE=on
LOGABSTRACT= "all"
EOL="
"
PID=$$
SPAMVAL=0
:0 ci #Initialize $PID.CTR (this sometimes doesn't happen????)
| echo -e 0 > spamtest/$PID.ctr
:0 D
* condition(s)
{
:0 ci #Increase value of $PID.ctr variable
| read var < spamtest/$PID.ctr && let var=var+1 && echo $var >
spamtest/$PID.ctr
}
# Numerous additional recipes
SPAMVAL=`cat spamtest/$PID.ctr`
LOG="Spamvalue=$SPAMVAL$EOL" #Just for logcheck in sandbox - will
disappear
:0 ci #Remove counter
| rm spamtest/$PID.ctr
:0 #Check for no hits
should be :0:, note the last : which means lock the mailbox before writing to
it.
* SPAMVAL ?? 0
spamtest/nohits
:0
:0:
spamtest/gotcha
=====================================
Does using the PID as a variable name make sense - or could I just as
easily use a single variable ($HITS.ctr for example)
any reason you don't use scores ? see man procmailsc for details.
NL="
"
:0
* 1^1 a
* 1^1 b
* 1^1 c
{ SCORE=$= }
# SCORE will be 0 if a, b or c aren't matched
# 1 if one the a, b or c if matched
# 3 if a, b and c are all matched
:0
* ! SCORE ?? 0
{
LOG="score: $SCORE$NL"
:0:
spamtest/gotcha
}
:0:
spamtest/nohits
Any reason anyone can think of that the $PID.ctr variable doesn't get
initialized every time?
Cyrille Lefevre.
--
home: mailto:cyrille(_dot_)lefevre(_at_)laposte(_dot_)net
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail