Something I have been thinking of trying for a while and I
finally did it this morning.  I thought I would pass it
along.

I wanted something -- a mailcheck and an alert.  A mailcheck
that would work with procmail because I have five different
mail folders that procmail sorts to.  An alert in the form
of a wav file that the computer could play.

What I mean by mailcheck is not on the order of fetchmail or
anything like that.  Just something to tell me I have unread
mail in my mailboxes -- when I am busy with something else.

I know there may be GUI solutions in KDE or Gnome, but I
don't use either of those desktops.  Besides, I am rather
fond of my own home-grown solution.

Here is the script -- I named it "m":

#!/bin/bash
cd ~/mail
if test
        du -b -c Austin-LUG Inbox NDS Newbie Xfce | grep total | grep 5120
                then echo No New Mail
                else /usr/bin/play ~/wavs/close03.wav
fi
exit 0

The first two lines are obvious.  The "if test" is a
conditional: it runs "du" with arguments on five different
mail folders.  (This is Pine I am dealing with so it may not
work with another mailbox format.)  Then it pipes into a
search for the "total" output; then it searches that output
for the number 5120.  5120 is the static number of bytes
indicating that each folder is one kilobyte, even with all
mail already read -- there is the "internal format" thing
that goes into this mailbox format.

Then, if "5120" is found, the output is "No New Mail."  If
it is not found, that means the number has increased and
there is new mail in a folder or folders.  So: else ...
It plays a wav file which is the five notes from the movie
"Close Encounters".

I tested this on a command line this morning and, to my
satisfaction, it works.  Later I made a crontab entry:

$ crontab -l
*/11 * * * * $HOME/bin/m >> $HOME/Procmail/log

Meaning the script is run every 11 minutes.  The output
(which with cron is normally sent as another e-mail) is
redirected to the Procmail log.  The double ">>" appends the
info to the log without erasing the rest of it.

Shell scripts are cool.  I hope maybe someone might want to
give it a try and experiment for themselves.

Phil

-- 
What makes the universe so hard to comprehend is that
there's nothing to compare it with.


Reply via email to