wa371@sdcc12.UUCP (Senior Gnome) (07/16/85)
Does anyone have a suggestion for a shell script for my .login file, which will announce immediately upon login whether I have mail or not, without putting me into the mail program if I don't want to be. It should run under the 4.2 c-shell. Thanks. Cheers, Bernd <bear-nd> *** hooray for USENET *** UUCP: ...!ucbvax!sdcsvax!sdcc12!wa371, ARPA: sdcsvax!sdcc12!wa371@nosc
ajd@yodel.UUCP (Andrew J. Davis) (07/19/85)
Under 4.2 flavored systems, the command "biff y", set .login will notify you if new mail arrives and who it is from. I believe this is what you want. Is this satisfactory? The command "biff n" disables new mail notification. Andrew J. Davis (617)-467-8366 DTN: 262-8366 U.S. Mail: Digital Equipment Corporation Internal Software Services Systems and Network Support IND-3/C10 67 Forest Street Marlboro, Mass. 01752 UUCP: decvax!yodel!ajd ENET: decwrl::rhea::yodel::ajd "Gentlemen, surely you're not going to take the word of a souless mechanical device over that of a real flesh and blood man."
jerryp@tektools.UUCP (Jerry Peek) (07/19/85)
[Doesn't this sort of thing belong in net.unix?] In article <411@sdcc12.UUCP> wa371@sdcc12.UUCP (Bernd) writes: > Does anyone have a suggestion for a shell script for my .login > file, which will announce immediately upon login whether I have mail > or not, without putting me into the mail program if I don't want > to be. > It should run under the 4.2 c-shell. Try this single line: if (! -z /usr/spool/mail/wa371) echo You have mail. Instead of hardcoding your login name (wa371), you could use $user instead. --Jerry Peek, UNIX Training Instructor, Tektronix, Inc. US Mail: MS 74-222, P.O. Box 500, Beaverton, OR 97077 uucp: {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp CS,ARPAnet: jerryp%tektools@tektronix.csnet Phone: 503/627-1603
larry@kitty.UUCP (Larry Lippman) (07/27/85)
> In article <411@sdcc12.UUCP> wa371@sdcc12.UUCP (Bernd) writes: > > Does anyone have a suggestion for a shell script for my .login > > file, which will announce immediately upon login whether I have mail > > or not, without putting me into the mail program if I don't want > > to be. > > It should run under the 4.2 c-shell. > > Try this single line: > > if (! -z /usr/spool/mail/wa371) echo You have mail. > > Instead of hardcoding your login name (wa371), you could use $user instead. Here is an alternative to the above which does not require knowing the mail spool path and file names: if (mail -e) echo 'You have mail.' The -e option should also be good for 'mailx' if that is what is on your machine. Larry Lippman Recognition Research Corp. Clarence, New York UUCP {decvax,dual,rocksanne,rocksvax,watmath}!sunybcs!kitty!larry {rice,shell}!baylor!kitty!larry syr!buf!kitty!larry VOICE 716/741-9185 TELEX {via WUI} 69-71461 answerback: ELGECOMCLR "Have you hugged your cat today?"
guy@sun.uucp (Guy Harris) (07/28/85)
> Here is an alternative to the above which does not require knowing the mail > spool path and file names: > > if (mail -e) echo 'You have mail.' This only works if you have the S3/S5 version of "mail". (Besides, they should have added a flag which tells "mail" to *print* a message instead of returning an exit status, 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).") > Guy Harris
chris@umcp-cs.UUCP (Chris Torek) (07/31/85)
I might note that our systems (and 4.3BSD) print You have mail. or You have new mail. when you log in, if you have mail or new mail. We put this in login.c long ago. The code is basically something like this: struct stat st; ... sprintf(buf, "%s/%s", MAILDIR, pwd->pw_name); if (stat(buf, &st) == 0) printf("You have %smail.\n", st.st_mtime > st.st_atime ? "new " : ""); -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
ado@elsie.UUCP (Arthur David Olson) (07/31/85)
> . . .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@seismo.ARPA DEC, VAX and Elsie are Digital Equipment and Borden trademarks
jmc@inset.UUCP (John Collins) (08/07/85)
In article <2509@sun.uucp> guy@sun.uucp (Guy Harris) writes: >.................... (Besides, they >should have added a flag which tells "mail" to *print* a message instead of >returning an exit status, 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).") > I agree - and at the same time why not tidy up all the commands which return the same exit status whatever happened to return different codes for different errors so that other programs can use standard utilities can work out what went wrong without deciphering stderr (when they use stderr!!). Mind you the Bourne shell is a bit vague about returning exit codes in a pipeline - so there are limits. -- John M Collins ....mcvax!ist!inset!jmc Phone: +44 727 57267 Snail Mail: 47 Cedarwood Drive, St Albans, Herts, AL4 0DN, England.