File Locking and Procmail 
Author Message
 File Locking and Procmail

Hi.  I'm trying to write a perl script to expire old articles from a
mail folder, which I maintain via procmail.

Basically I accumulate incoming articles into a file with a simple procmail
rule.  What I want to do is delete articles that are more than a certain
number of days old, or retain the most recent 1000 articles, or whatever.
I have that part of the logic working correctly.

The thing I want to know is, how do a lock my mail folder in a way that
will guarantee peaceful coexistence with procmail?

When I do "procmail -v" I get the following:

   Locking strategies: dotlocking, fcntl()

Does this mean I have to do *both* of these things?  I'm aware of the
fcntl() function in perl, as well as "use Fcntl", but do I need to do more?

Next question: My script does an initial scan of the file (to get an
article count), closes it, and then re-opens it to kill the old articles.
Can I close, and then re-open a file without losing the fcntl-style lock?
Or am I reliant on dot-locking in this case?

Also, if there is a way to invoke the script from *inside* procmail, so
that procmail handles the locking for me, that would be pretty sweet.

Lastly, it seems like this application (expiring old articles from a mail
folder) would be something easy to do inside procmail, or that someone else
has already figured out a slick way to handle this.  Any info along those
lines would be greatly appreciated.

I'm running Perl 5.003 on Freebsd 2.1.7, Procmail v3.11pre4.

Thanks in advance, as always.

--
+------------------------------------------------------------------+

| Progress DBMS Stuff: http://www.*-*-*.com/ ~rss/progress-faq.html |
+------------------------------------------------------------------+



Tue, 11 Jan 2000 03:00:00 GMT  
 File Locking and Procmail


Quote:

>When I do "procmail -v" I get the following:

>   Locking strategies: dotlocking, fcntl()

>Does this mean I have to do *both* of these things?  I'm aware of the
>fcntl() function in perl, as well as "use Fcntl", but do I need to do more?

Better check the procmail sources to see what is required.

Quote:
>Next question: My script does an initial scan of the file (to get an
>article count), closes it, and then re-opens it to kill the old articles.
>Can I close, and then re-open a file without losing the fcntl-style lock?
>Or am I reliant on dot-locking in this case?

The loose the lock upon closing. Better open the file R/W and seek back to
the beginning after the first pass.

Quote:
>I'm running Perl 5.003 on Freebsd 2.1.7, Procmail v3.11pre4.

You should upgrade to perl5.004_01, it has some changes regarding flock
(and setuid scripts will work again on FreeBSD :-)

ciao
  lutz
--

Do not take life too seriously, you will never get out of it alive.



Wed, 12 Jan 2000 03:00:00 GMT  
 File Locking and Procmail

Quote:


> >When I do "procmail -v" I get the following:
> >   Locking strategies: dotlocking, fcntl()
> >Does this mean I have to do *both* of these things?  I'm aware of the
> >fcntl() function in perl, as well as "use Fcntl", but do I need to do more?
> Better check the procmail sources to see what is required.

Heh. That's a death sentence right there.  Few large programs have code
as impentrable as the procmail package.

Quote:
> >I'm running Perl 5.003 on Freebsd 2.1.7, Procmail v3.11pre4.
> You should upgrade to perl5.004_01, it has some changes regarding flock
> (and setuid scripts will work again on FreeBSD :-)

You should upgrade to procmail v3.11pre7 it has some useful bug fixes.

Anyway, Richard, your best bet here is to use the "lockfile" program
that came with procmail. It creates lockfiles with the same conventions
as those used by the ":0:lockfile" and "LOCKFILE=lockfile" constructs
in procmailrc files.

Elijah
------
is trying to hack procmail to embed perl



Fri, 14 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. header files for scripts run from procmail?

2. PERLFUNC: flock - lock an entire file with an advisory lock

3. PERLFUNC: flock - lock an entire file with an advisory lock

4. File Locking and File Deletion

5. File altering in-place w/ file locking

6. File Locking with tied [GNS]?DBM files...

7. taint checks, AIX 3.2.5, procmail and deep frustration

8. procmail-invoked perl

9. Procmail - domain forwarding

10. Perl & Procmail Interface Scripting

11. Procmail?

12. newbie perl procmail ?

 

 
Powered by phpBB® Forum Software