home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3626 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.4 KB  |  52 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!mcsun!sunic!ugle.unit.no!news
  3. From: Harald.Eikrem@delab.sintef.no
  4. Subject: Re: tcsh: How to disable printing motd w/o disabling mail check?
  5. In-Reply-To: forest@soda.berkeley.edu's message of 25 Aug 1992 16:32:46 GMT
  6. Message-ID: <1992Aug26.120939*Harald.Eikrem@delab.sintef.no>
  7. Sender: news@ugle.unit.no (NetNews Administrator)
  8. Organization: SINTEF DELAB, Trondheim, Norway.
  9. References: <17dnbeINNq2f@agate.berkeley.edu>
  10. Date: 26 Aug 92 12:09:39
  11. Lines: 39
  12.  
  13. ! I have considered adding a .hushlogin, and a shell script or short
  14. ! program to check the status of my mailbox, but I'm not sure how to
  15. ! write one that will distinguish new mail from old.
  16. !
  17. ! Any suggestions?
  18.  
  19. Not exacly your typical shell script, but...
  20.  
  21. I know I really should have included stat.pl (i.e. "require 'stat.pl'") in
  22. order to use symbolic indexing with mstat, but regrettably our sys admin
  23. haven't gotten around to h2pl conversion yet.
  24.  
  25.   ~~harald E.
  26.  
  27. ========chkmail========
  28. #!/local/bin/perl
  29.  
  30. $mail = @ENV{"MAIL"};
  31.  
  32. if ( ! $mail || ! -r $mail ) {
  33.     $user = (getpwuid($<))[0] if !($user = getlogin);
  34.  
  35.     if ( -r "/usr/spool/mail/$user" ) {
  36.     $mail = "/usr/spool/mail/$user";
  37.     } elsif ( -r "/usr/mail/$user" ) {
  38.     $mail = "/usr/mail/$user";
  39.     } else {
  40.     exit 1;
  41.     }
  42. }
  43.  
  44. @mstat = stat($mail);
  45.  
  46. exit 1 if ! @mstat[7];
  47.  
  48. $new = " new" if @mstat[8] < @mstat[9];
  49. print "You have$new mail.\n";
  50. exit 0;
  51. =======================
  52.