procmail
[Top] [All Lists]

Re: Counting rule and skip?

1996-08-23 12:58:12
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?


  :0
  * ^From(_dot_)*joe\(_dot_)blow(_at_)foo\(_dot_)com
  {
   COUNTERFILE=path/to/counter/file
   OLDSHELL=$SHELL SHELL=/bin/sh # in case your $SHELL is csh-based
   MAXTIMES=9

   :0c:
   * $ -`wc -l < $COUNTERFILE 2>&1 || echo 0`^0
   * $ $MAXTIMES^0
   JOE
    :0Ahi: # local lockfile might be unnecessary, but let's play safe
    | echo >> $COUNTERFILE

   :0Eh
   /dev/null

   SHELL=$OLDSHELL # in case of fall-through on error
  }

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