procmail
[Top] [All Lists]

Re: counting messages since last login

1996-04-09 08:57:12
-----BEGIN PGP SIGNED MESSAGE-----

On Tue, 9 Apr 1996, Timothy J. Luoma wrote:

Date: Tue, 9 Apr 1996 10:15:43 -0400 (EDT)
From: Timothy J. Luoma 
<luomat(_at_)cedman(_dot_)remote(_dot_)Princeton(_dot_)EDU>
To: Guy Geens <Guy(_dot_)Geens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be>
Subject: Re: counting messages since last login

Here's the script:

#!/bin/sh

file=/Users/luomat/.procmail-count

if [ -r $file ]
then
      # IF $file exists
      current=`/bin/cat $file`
#     echo current count is $current
      new=`expr $current + 1`
#     echo new is $new
      echo $new > $file
else
      # IF $file does not exist
      echo "1" > $file
fi

# end


Here's the recipe (the first in my .procmailrc)

:0c
|count_mail

The errors are caused by the script running twice, using the same count file.
You need a lockfile. Add a `:' behind the :0c and you should be just fine.


Guy Geens <guy(_dot_)geens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be>: Ph.D. 
student at ELIS -- TFCG / IMEC 
Atypical civil engineer -- And proud of it!
(Please check out http://www.elis.rug.ac.be/ieeesb/civil.html)
Home Page: http://www.elis.rug.ac.be/ELISgroups/tfcg/staff/gg.html 
finger ggeens(_at_)elis(_dot_)rug(_dot_)ac(_dot_)be for PGP public keys (or use 
keyserver) 


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: pgp fingerprints in message headers

iQBVAwUBMWqHg3wHoCha5QR1AQFFNgH/cV+RhbNIJPgRH2RSJDBY+id0I3DXvLD/
WjyBm01cFwWyFZtn0URsQ10WXBli2aqZ1wEgVX3Wt51b+aEjHcYtWA==
=9UpV
-----END PGP SIGNATURE-----

<Prev in Thread] Current Thread [Next in Thread>