procmail
[Top] [All Lists]

Checking Message-Id: cache without updating?

2003-01-12 19:05:54
Hi guys,

   It's been a long time since I posted to this list.  I'm finally back,
   this time with a question.  :)

   What's the best way to check if a Message-ID has been put into the
   cache that formail maintains *without* actually updating the cache?

   I'm using procmail as a wrapper around mailing lists.  Previously
   I had been using the standard formail recipe before calling the
   MLM, i.e.

      :0 Wh: $HOME/list-cache/${LIST}.lock
      | formail -D 32768 $HOME/list-cache/${LIST}.cache

   This generally works well unless the MLM fails for some reason.  At
   that point I requeue the messages, but they're already in the 
   cache and will fail on subsequent delivery attempts.

   OK, no problem.  I figured that I'd only call formail -D if delivery
   to the MLM was successful.  Before calling the MLM I'd just grep 
   in the cache to see if it was there or not.  i.e.

      :0
      * ! ^Approved:
      * ^Message-Id: \/.*
      * ? fgrep -q "$MATCH" $HOME/list-cache/${LIST}.cache
      /dev/null

      :0
      * MLM ?? ^(majordomo)$
      { 
         :0c
         | $HOME/wrapper resend -l $LIST $LIST-secret-$DOMAIN,$EXTRA

         :0
         {
            :0 Wah: $HOME/list-cache/${LIST}.lock
            | formail -D 32768 $HOME/list-cache/${LIST}.cache
      
            :0
            /dev/null
         }
      }

   This works for the most part, but there are times when the Message-ID
   has special characters that mess up the matching.  For example, a 
   header with a bracketed IP address will fail the grep because of the
   brackets:

      Message-ID: <a05200f00ba4727253e43(_at_)[192(_dot_)168(_dot_)1(_dot_)102]>

   I figure that sed is the best tool to use here; I can just escape
   special characters with a backslash prior to sending it to grep.  

   The thing is, I know nothing about sed.  :)  After spending way too
   much time trying to figure this out, I'm throwing in the towel.  Does
   anyone out there with more sed experience have a way to escape those
   characters?  I found a related message at

      
http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/2000-04/msg00141.html

   but can't seem to heads or tails of the sed syntax there.  I have a 
   working perl version (piece o' cake!), but I really want to avoid  
   perl's overhead.

Thanks for any tips,

Chris

_______________________________________________
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>