procmail
[Top] [All Lists]

Re: Skimming files out of a mail folder (semi-procmail related question).

1996-11-27 15:22:21
    > Greetings procmail folks,
    > 
    >     I have a project that will be using procmail to do what it does best,
    >     directing certain mail messages into a particular mail folder based on
    >     some header criteria (in this case, the "To:" address).
    > 
    >     While procmail is collecting these messages, every once in a while, 
    >     (outside of procmail) I want to process them using an interactive
    >     program. My question is; what is the best way to quickly remove the
    >     messages from the folder before processing them.  For example, would
    >     something like:
    > 
    >           % mv foo-folder new-requests            # rename the folder
    >           % touch foo-folder                      # make a new empty one
    >           % my-processor <new-requests            # process last batch of 
msgs.
    > 
    >     do the trick -- that is, give me access to the latest batch of 
messages
    >     collected in the foo-folder without messing up procmail and without 
the
    >     possibility of dropping a message on the floor that might happen to
    >     arrive while I'm doing the switch-a-roo?  Or is there a better and
    >     safer approach to this?

Use the *same* locking protocol as is used to put messages there in the
first place.  If you use a procmail recipe to drop messages into
"foo-folder", eg:

    :0:
    foo-folder

Since this recipe implicitly creates the lockfile
"foo-folder.$LOCKEXT", where $LOCKEXT is typically defined as ".lock"
in most procmail configurations, then, you should use the "lockfile"
command to protect the change-over:

    lockfile foo-folder.lock
    mv foo-folder new-requests
    touch foo-folder
    rm -f foo-folder.lock

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