checkmail (a cute little mailchecking utility)

Tim Maroney tim at hoptoad.uucp
Fri Aug 15 12:56:20 AEST 1986


It's been a while since I mentioned this trick I worked up a cuple of years
ago, so I thought I'd distribute it again:

The problem is that most of us have mailboxes which have back mail in them,
so the login message "You have mail." tells us nothing.  Scanning the
mailbox takes too long on login.  What we really want to know is whether
mail arrived while we were logged out.

A few commands in the .login and .logout scripts suffices to do this easily,
quickly, and efficiently.  (This version is for csh; I'm sure a similar
approach would work for sh, but I don't feel like researching that silly old
thing...)  The approach is that at logout you touch an empty file in your
home directory, and at login compare the date of the file to the date of
your mailbox.  If the date on the mailbox is newer, then new mail has
arrived, and the login script so informs you.

Here is the line in the .logout file, where the name of the empty file is
".m" in the home directory:

touch ~/.m

And here are the commands in the .login file:

set m=`ls -t $mail .m`
if ($m[1] == /usr/spool/mail/tim) then
	echo Read your mail, why don\'t you\?
endif

To start up the system, you will have to create the .m file in your home
directory; the easiest way is probably "cat > .m" followed by an end of
file.
-- 
Tim Maroney, Electronic Village Idiot
{ihnp4,sun,well,ptsfa,lll-crg,frog}!hoptoad!tim (uucp)
hoptoad!tim at lll-crg (arpa)

Give me food, or give me slack (or kill me).



More information about the Comp.sources.unix mailing list