The msgchk command will tell you whether there's mail waiting for you. Here's an example:
% msgchk
You have new mail waiting; last read on Mon, 09 Jan 1995 14:37:09
Many UNIX hosts with local mailboxes output a message, like
You have mail, if messages are waiting as you log in. If
your host doesn't, you can do it by adding a call to msgchk
in your shell setup file (.login, .profile). To
suppress the message when there's no mail, save the msgchk
output in a shell variable and test the
exit status. A non-zero status means
that there were no messages -- or some other problem.
The next Example shows how:
Example: Automatic mail check in shell setup
file
Bourne and Korn shells:
if msgs=`msgchk`
then echo "$msgs"
fi
C shell:
set msgs=(`msgchk`)
if ($status == 0) echo "$msgs"
mgschk also works across a network with POP; the
Section Using MH with POP has basic
information.
This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. It is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see COPYING.
|
Copyright © 1991, 1992, 1995 O'Reilly Media, Inc. Last modified: 2006-05-31 15:13:43 -0700 |
|