procmail
[Top] [All Lists]

Re: Filtering already saved messages

1998-05-18 06:35:02
On Mon, 18 May 1998 08:24:18 -0400 (EDT), Matt Cortes
<link(_at_)alpha(_dot_)pulsar(_dot_)net> wrote:
On Mon, 18 May 1998, Heinz Diehl wrote:
On Sun May 17, 1998 at 11:23:53PM -0400, Matt Cortes wrote:
Ok, maybe I babbled in that last message. heh.. Simply put, I'd
like to know how I can filter my already existing mailbox
through procmail. Is it as simple as "cat mbox | procmail"??
Try `cat <mailfile> | formail -ds procmail
What's the difference between the script in the procmail man file (Just
found that one out) and the commandline you just gave me?  Does it process
any differently?

It wastes one process on the unnecessary cat(*), and doesn't do any of
the locking that the thing in the man page does. 
  You don't need locking if you have an old file with some messages in
it which you want to reprocess; you +really+ want the locking if the
file you want to process is an active inbox which might receive more
mail at any time. This is always the case when you're processing your
primary inbox file, which is what the cron example in the man page is
about.

Here's a pseudocode version of the man page example:

    Place a lock on the temporary file we're going to use.
    Place a lock on the primary inbox.
    Move the stuff in the temporary inbox to the temp file.
    Unlock the primary inbox.
    formail -s procmail <temp file
    Unlock temp file.

As long as the locks are in place, they should prevent others from
writing to these files. I say "should" because the locking is not
necessarily adhered to by every program you use -- but the cron job
example is at least taking care to avoid clashes with incoming mail
being delivered by a well-behaving mail program. (On some systems, you
could easily mess things up by doing cat mbox >>$MAIL while a piece of
mail is arriving, because cat doesn't care about lock files.)

/* era */

(*) <http://www.iki.fi/~era/unix/award.html>

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>