procmail
[Top] [All Lists]

Re: next musing: deleting a file within procmail

2001-07-09 21:39:40
On  9 Jul, David W. Tamkin wrote:
| OK, next notion: is there any way to make procmail delete a file without its
| calling an external program?  My only thought is to make procmail think that
| the file is some other process's stale lockfile; then procmail would comman-
| deer it (does that involve removing and re-creating or just touching?) and,
| being done with its own use for the file, remove it.  But seventeen minutes
| of having procmail spin in place seem more costly than a fork of rm.

This seems to work (with v3.13.1):

Script started on Tue Jul 10 00:39:44 2001
00:39:44 [1] $ : >testlog.dattier
00:39:56 [2] $ echo testing >LOCKFILE
00:40:09 [3] $ cat .testrc.dattier2
# .testrc
TESTDIR=$HOME/.procmail/test
LOGABSTRACT=no
PATH=/bin:/usr/bin:$PATH
LOGFILERC=$TESTDIR/testlog.dattier
LOGFILE=$LOGFILERC
NL="
"
xLOCKTIMEOUT=$LOCKTIMEOUT
xTIMEOUT=$TIMEOUT
xSUSPEND=$SUSPEND
LOCKTIMEOUT=1
TIMEOUT=1
SUSPEND=1
VERBOSE=yes
:0:LOCKFILE
{ }

LOCKTIMEOUT=$xLOCKTIMEOUT
TIMEOUT=$xTIMEOUT
SUSPEND=$xSUSPEND

:0
/dev/null

00:40:15 [4] $ 
00:40:20 [4] $ procmail ./.testrc.dattier2 </dev/null
00:40:22 [5] $ 
00:40:24 [5] $ cat testlog.dattier
procmail: [23507] Tue Jul 10 00:40:21 2001
procmail: Extraneous locallockfile ignored
procmail: Locking "LOCKFILE"
procmail: Forcing lock on "LOCKFILE"
procmail: [23507] Tue Jul 10 00:40:22 2001
procmail: Locking "LOCKFILE"
procmail: Unlocking "LOCKFILE"
procmail: Assigning "LOCKTIMEOUT="
procmail: Assigning "TIMEOUT="
procmail: Assigning "SUSPEND="
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
/home/deh/.procmail/test/
00:40:41 [6] $ ls LOCKFILE
ls: LOCKFILE: No such file or directory
status 1
/home/deh/.procmail/test/
00:40:47 [7] $ exit

Script done on Tue Jul 10 00:40:49 2001

I hit enter as quickly before and after executing procmail to show the
time in the prompt: ~2 seconds. It complains about the extraneous
lockfile, but removes it before contimuing on to the next recipe.

-- 
                         /"\
Don Hammond              \ /     ASCII Ribbon Campaign
Raleigh, NC US            X        Against HTML Mail,
                         / \      and News Too

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail