On Tue, Nov 16, 1999 at 11:00:59AM +0200, era eriksson wrote:
On Tue, 16 Nov 1999 12:02:04 +1300 (NZDT), Volker Kuhlmann
<kuhlmav(_at_)elec(_dot_)canterbury(_dot_)ac(_dot_)nz> wrote:
> You don't need cron, just outsmart the sysop with something like this,
> run each time you log in or out:
> #!/bin/tcsh -f
(Ugh.)
> The real problem is to remove msgs piped into procmail from your
> mail spool file in a way which doesn't lose anything... (perhaps
> lockfile will help - I think I never had much luck in getting it to
> go)
Actually the "crontab" example in the NOTES section of the procmail(1)
manual page is supposed to solve exactly that. You can run it in a
while loop like you demonstrated just as well as from a crontab entry
or an at job.
Quoted below for our lazy friends. Do note that ORGMAIL is system
specific; you'll have to check your version of the manual page or do
some other sort of (gasp!) research to figure out what's right for
your system.
Hope this helps,
/* era */
Procmail can also be invoked to postprocess an already filled system
mailbox. This can be useful if you don't want to or can't use a
$HOME/.forward file (in which case the following script could
periodically be called from within cron(1), or whenever you start
reading mail):
#!/bin/sh
# Remove this line when you understand what it means; see comment above
echo "You need to change the ORGMAIL setting in this script"; exit 1
ORGMAIL=/usr/spool/mail/$LOGNAME
if cd $HOME &&
test -s $ORGMAIL &&
lockfile -r0 -l3600 .newmail.lock 2>/dev/null
then
trap "rm -f .newmail.lock" 1 2 3 15
umask 077
lockfile -l3600 -ml
cat $ORGMAIL >>.newmail &&
cat /dev/null >$ORGMAIL
lockfile -mu
formail -s procmail <.newmail &&
rm -f .newmail
rm -f .newmail.lock
fi
exit 0
--
Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition
I've been using this script for quite a while now until I had to realize
that apparently mails are disappearing. My .procmailrc is very simple:
#
# The litte brothers database extracts email addresses and
# stores it in ~/mail/
#
:0hc
| /home/zie/bin/linux/lbdb-fetchaddr
:0:
* ^TO(_dot_)*procmail(_at_)*
$HOME/mail/procmail
:0:
* ^TO(_dot_)*linux-sh(_at_)*
$HOME/mail/linux-sh
:0:
* ^Subject:.*iis-all
$HOME/mail/iisall
:0:
* ^Subject:.*inel-all
$HOME/mail/inel-all
:0
* ^From.*zie
* ^Subject:.*test
{
:0
$HOME/mail/zie.test
}
As it does not contain any DEFAULT-variable, procmail reads from the
standard system mailbox and writes the result back to it again. The docu
says, that procmail locks the system mailbox before doing any operation on
it. If sendmail is already writing to the system mailbox -- e.g. after
receiving a new message --, procmail should detect that as well and delay
the write process.
The only way I can imagine how my mails have been deleted is, that the
locking mechanism does not work as described above. I imagine, that procmail
_overwrites_ a just received message.
Any comments / hints how to solve my problem?
Thomas
PS: System environment
- OS: linux
- mailer: mutt
- formail-script started by cron once a minute
- /var/spool/mail mounted by automounter from office mailhub
- no root privileges
--
Dr.-Ing Thomas Ziegler Phone +49 9131 776-348
FhG-IIS A, Audio/Multimedia FAX +49 9131 776-398
Am Weichselgarten 3
D-91058 Erlangen