procmail
[Top] [All Lists]

RE: reprocessing mail

2001-12-05 10:46:38


-----Original Message-----
From: procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
[mailto:procmail-admin(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE]On Behalf Of 
Gary Funck
Sent: Saturday, December 01, 2001 2:36 PM
To: procmail(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
Subject: RE: reprocessing mail



Brad writes:
Sent: Tuesday, December 04, 2001 1:58 PM
To: procmail(_at_)Lists(_dot_)RWTH-Aachen(_dot_)DE
Subject: reprocessing mail


I had a script that would rum all mbox back threw my procmail filter
when i changed the .procmailrc file, but lost it some time
ago. anyone
have a script that the can send me? or url that has one?


Q: If you reprocess your mail won't your procmail scripts
re-file e-mails
that have already been filed?  That seems undesirable.

Although I don't have a ready-made script, here is an outline
that you might
be able to work from.  The key points are that you need to
make sure and
lock the mailbox first, then move it to a temporary file,
then process the
temporary (old mail) file, remove it, and release the lock.

THIS IS UNTESTED.

#!/bin/csh -f
lockfile -ml
if ($status != 0) then
  echo "attempt to lock $MAIL failed."
  exit 2
endif
if (-e $MAIL) then
  mv $MAIL ${MAIL}.old
  formail -s procmail < ${MAIL}.old
  rm -f ${MAIL}.old
endif
lockfile -mu


Although Dallman Ross has already pointed out that this is a FAQ, and an
example in the manpage, where a better (and correct) implementation is
detailed, let me point out that in my example above, that the file lock
should be released prior to running formail/procmail, and not at the end
of the script, otherwise a dead lock will likely occur.  Rewriting:

#!/bin/csh -f
lockfile -ml
if ($status != 0) then
  echo "attempt to lock $MAIL failed."
  exit 2
endif
if (-e $MAIL) then
  mv $MAIL ${MAIL}.old
  lockfile -mu
  formail -s procmail < ${MAIL}.old
  rm -f ${MAIL}.old
else
  lockfile -mu
endif

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