procmail
[Top] [All Lists]

Re: Cloning within a LOCKFILE block

1997-10-13 18:52:54
At 06:50 PM 10/13/97 -0500, Philip Guenther wrote:
Basically, in my .procmailrc I have:

  :0c:file.lockfile
  {
     "file" must not be modified while in here
  }

If the recipes inside the braces try to use file.lockfile as a lockfile,
then you'll have a deadlock situation.  Would you consider including the
actual code involved?

Sure, It is posted below.  Feel free to hack away, as I'm sure there are
better ways to do many of these things.  I always appreciate the suggestions.


So "W" is implicit.  That's good to know -- I always though procmail
actually forked or some such thing.  So I'm better of WITHOUT the w flag
since I really don't care about any error messages in the log.

David suggested that if the child fell through the bottom brace that I'd
end up in a lock file situation, which makes sense.


Here's the code: When I get email, .procmailrc checks a date in a file
against the current date, and if different, drops a "summary" file in my
inbox.

   SUMARYLOCK=$SPAMDIR/summary.spam$LOCKEXT

   TODAY=`date '+%m-%d-%y'`
   CURRENT

   :0ic # suppose I could check test -f the file first, but I'm lazy
   CURRENT=| cat $SPAMDIR/currentdate.spam

   :0e
   { CURRENT="unknown" }


   # not really sure why I need the w here

   :0cw:$SUMMARYLOCK
   * TODAY ?? ! $ ^^$\CURRENT^^
   {
      DUMMY=`echo $TODAY > $SPAMDIR/currentdate.spam`


      :0 # if summary doesn't exist create a message
      * ? test ! -f $SPAMDIR/summary.spam
      { DUMMY=`echo "--- No spam detected for $CURRENT ---">
$SPAMDIR/summary.spam` }


      :0fiw
      | (echo "From moseley(_at_)netcom(_dot_)com `date`"; \
         echo "To: moseley(_at_)netcom(_dot_)com"; \
         echo "From: Spam Summary <moseley(_at_)netcom(_dot_)com>"; \
         echo "Date: $TIMESTAMP"; \
         echo "Subject: Spam Summary for $CURRENT"; \
         echo "Received: by procmail at $TIMESTAMP for moseley
<moseley(_at_)whmoak>"; \
         echo ""; \
         cat $SPAMDIR/summary.spam; \
         echo ""; \
         rm -f $SPAMDIR/summary.spam)

         # I guess I could just >> $ORGMAIL above

      # and drop in inbox
      :0:
      $ORGMAIL
   }


.... then later in the rc:


   #----- Now add header info from archived message to today's summary
---------
   #  (Note: uses same lock as above)

   :0hic:$SUMMARYLOCK
   | ( \
       echo "Spam ID: $MESSAGENUM     ( $TIMESTAMP )"; \
       echo "     To: $TO"; \
       echo "     Cc: $CC"; \
       echo "   From: $FROM"; \
       echo "   Date: $DATE"; \
       echo "Subject: $SUBJECT"; \
       echo " "; \
       echo "       ----- Rejected Reason(s) -----"; \
       echo "$REJECT_REASON"; \
       echo " "; \
       echo "--------------------------------------------------------"; \
       echo " " \
     ) >> $SPAMDIR/summary.spam





Bill Moseley
mailto:moseley(_at_)netcom(_dot_)com

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