procmail
[Top] [All Lists]

Re: Avoiding unnecessary call

2001-01-07 11:41:35
++ 06/01/01 15:40 -0600 - Philip Guenther:
Make that three solutions: rather than capturing grep's output, just
check its return code:
[...]

That is a good idea as well.

You said the current solution won't work. That surprises me, as the as
it seemed to work for the past few days - but than again, there are only
a very limited number of votings running which could explain why i
haven't got into trouble yet.

I'll try to free sometime tonight to do some testing with the setup
Dallman suggested. 

      :0
      * ^Envelope-To: stemformulieren(_at_)sisterray\(_dot_)xs4all\(_dot_)nl
      * ^Subject: .*\/nl\.[-a-z_0-9.]+
      * ? grep -i "${MATCH}.*Running" ${VOTEDIR}/stemmingen.txt >/dev/null
      {
          :0 c:
          $VOTEDIR/$MATCH/backup/votes

          :0:
          $VOTEDIR/$MATCH/votes
      }

That's efficient because procmail will skip the rest of the conditions
on a recipe as soon as non-scoring condition fails, or if a scoring
condition pushes the accumulated score to "negative infinity**".  So,
if the subject doesn't match, the grep won't run.

Note that I tightened up the regexp used to match the newsgroup name,
to keep people from putting "*"s and the like in to scan for votes
going on.  Hmm, are accented characters allowed and/or used in newsgroup
names in Europe?

For other hiearchies, i can't speak. For the dutch one, the one starting
with nl., no accented characters are allowed. However, you still did
miss one in the presented regexp: the + is a valid character in a
newsgroup name.

And, another thing is, people who try to mess with the filters by adding
a * to the groupname in the Subject won't have their vote counted as
checks in other scripts (after this filter) are too tight.

Anyway, i will change that regexp to "nl\.[-a-z_0-9.+]+", which i guess
make it accept + s as well.

I also quoted the match in the grep command.  That'll keep the shell
from trying to perform filename expansion on the pattern argument to
the grep command.  Hmm, You could actually get a false match there if
two newsgroups differ by a dot, or if one is a substring of another.
We would need to know more about the format of the stemmingen.txt file
to fix that.  Knowing your version of grep (or OS) may make that
easier.

$ uname -sr
Linux 2.2.16

$ grep -V
grep (GNU grep) 2.4
[...]

$ cat vote/current/stemmingen.txt 
GROEP                           START           EIND            DUUR    NOTES 
(V:T:B:O)
nl.actualiteiten                2000-08-13      2000-09-09      4w      
Cancelled op 2000/08/15.
nl.muziek.instrument.toetsen    2000-08-13      2000-09-09      4w      
Aangenomen 74:11:3:6
nl.comp.handheld                2000-08-20      2000-09-16      4w      
Aangenomen 105:6:0:6
nl.kunst.overig                 2000-09-03      2000-09-30      4w      
Afgekeurd 32:2:0:3
nl.ondernemen                   2000-09-03      2000-09-30      4w      
Aangenomen 83:4:1:10
nl.sport.vechtsport             2000-09-09      2000-10-07      4w      
Aangenomen 62:10:1:1
nl.eeuwig.disney                2000-11-12      2000-12-02      3w      
Afgekeurd 57:60:0:9
nl.comp.cad-cam                 2000-11-19      2000-12-09      3w      
Cancelled op 2000/11/22.
nl.eeuwig.test                  2000-11-26      2000-12-23      4w      
Afgekeurd 53:51:0:1
nl.comp.cad-cam                 2000-11-26      2000-12-16      3w      
Afgekeurd 29:1:0:11
nl.newsgroups.stemadressen      2000-12-03      2000-12-23      3w      
Afgekeurd 6:49:0:1
nl.fan.disney                   2000-12-10      2000-12-30      3w      
Cancelled op 2000/12/13.
nl.support.orthopedagogie       2000-12-10      2001-01-06      4w      Running.
nl.media.ansichtkaart           2000-12-17      2001-01-06      3w      Running.

The fourth column are the number of weeks the CFV is running and is needed
by other scripts. The last column is relevant for us, as that one will be
used to determine if a voting is running. It is, like the last two, it will
have the word Running there, otherwise other words will indicate the current
state.
 
Votings at the same time for groups that differ by only a dot is extremely
rare, however votings for newsgroups of which one is a substring of the
other, that could be possible.

Please note, i can change the order of the columns if needed. I guess it
will be made a lot eassier if the GROUP and NOTES are next to each other so
one can test for whitespace only between the groupname and Running. Correct?

Thanks a lot for all of your help!

        -R.


-- 
# rejo(_at_)sisterray(_dot_)xs4all(_dot_)nl (pgp: see headers) - 
http://www.sisterray.nl
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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