home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!mcsun!sunic!ugle.unit.no!news
- From: Harald.Eikrem@delab.sintef.no
- Subject: Re: tcsh: How to disable printing motd w/o disabling mail check?
- In-Reply-To: forest@soda.berkeley.edu's message of 25 Aug 1992 16:32:46 GMT
- Message-ID: <1992Aug26.120939*Harald.Eikrem@delab.sintef.no>
- Sender: news@ugle.unit.no (NetNews Administrator)
- Organization: SINTEF DELAB, Trondheim, Norway.
- References: <17dnbeINNq2f@agate.berkeley.edu>
- Date: 26 Aug 92 12:09:39
- Lines: 39
-
- ! I have considered adding a .hushlogin, and a shell script or short
- ! program to check the status of my mailbox, but I'm not sure how to
- ! write one that will distinguish new mail from old.
- !
- ! Any suggestions?
-
- Not exacly your typical shell script, but...
-
- I know I really should have included stat.pl (i.e. "require 'stat.pl'") in
- order to use symbolic indexing with mstat, but regrettably our sys admin
- haven't gotten around to h2pl conversion yet.
-
- ~~harald E.
-
- ========chkmail========
- #!/local/bin/perl
-
- $mail = @ENV{"MAIL"};
-
- if ( ! $mail || ! -r $mail ) {
- $user = (getpwuid($<))[0] if !($user = getlogin);
-
- if ( -r "/usr/spool/mail/$user" ) {
- $mail = "/usr/spool/mail/$user";
- } elsif ( -r "/usr/mail/$user" ) {
- $mail = "/usr/mail/$user";
- } else {
- exit 1;
- }
- }
-
- @mstat = stat($mail);
-
- exit 1 if ! @mstat[7];
-
- $new = " new" if @mstat[8] < @mstat[9];
- print "You have$new mail.\n";
- exit 0;
- =======================
-