mailwatch script wanted
Arthur David Olson
ado at elsie.UUCP
Wed Jul 31 11:45:18 AEST 1985
> . . .they should have added a flag which tells "mail" to *print* a message
> . . .or to return one of *three* exit statuses. That way, you can distinguish
> "You have mail (because you leave stuff around in your mailbox until you've
> responded to it)" from "You have mail (because some mail arrived since the
> last time you looked at your mailbox).")
For those running 4.?bsd and using the C shell, here's an odd way to do pull off
the second trick. Add this line to your ".cshrc" file
alias mail '/usr/ucb/mail \!* ; if ( "\!*" == "" ) chmod u+s $mail'
(substituting for "/usr/ucb/mail" as appropriate) and this line to your
".login" file
find $mail \! -perm -4000 -exec echo "You have new mail." \;
(ensuring that "$mail" gets set before this point in the ".login" file).
Given the alias, the set-user-id bit of your mail file will be set each time
you read your mail. Given the way 4.?bsd works, the set-user-id bit is cleared
each time mail is written to your file. The "find" command simply checks the
bit to determine whether or not you have "new" mail.
--
UNIX is an AT&T Bell Laboratories trademark.
Sun is a Sun Microsystems trademark.
An AT&T employee holds a patent on the set-user-ID bit.
--
UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado at seismo.ARPA
DEC, VAX and Elsie are Digital Equipment and Borden trademarks
More information about the Comp.unix.wizards
mailing list