procmail
[Top] [All Lists]

Re: how to deliver to a file with a unique time-stamped file name, reliably?

2005-01-18 19:12:01
On Tue, 18 Jan 2005 16:36:53 -0800, Gary Funck <gary(_at_)intrepid(_dot_)com> 
wrote:
FIND="TEXT-TO-FIND"
MYDATE=`date '+%d%m%Y%H%M%S'`
:0
* ^TO_user(_at_)domain(_dot_)com
* $ B ?? $FIND
{
  :0c # Write the email, fork a copy
  $MYDATE

   :0a # process the copy of the mail
   |  /tmp/processmail.sh
}

Not bad, but how do we make sure that the file named by $MYDATE
isn't overwritten by another process executing this script within
the same second in time?

We don't.  But then again, that wasn't part of the spec. :)

That said, it is trivial to do this.  simplest way would be to lock
the $MYDATE file and have the script be able to deal intelligently
with multiple mails in the same mbox file, or add a random tag to the
end of the file name.

-- 
<http://2blog.kreme.com/blog/2944/Twas_the_Night_Before_Christmas>

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail