brennan@rtp.dg.com (Dave Brennan) (04/09/90)
Here's a script I wrote that users around here have found useful. I hope
the people reading this group will find it useful as well. This script
prints information about the message in your mailbox. For example:
% ckmail
Mailbox brennan: 2 new, 6 unseen, 35 old messages.
# ckmail
Mailbox root: empty.
There's probably a faster way to do this, but I just wanted to get it to
work with as little effort as possible. Enjoy!
#!/bin/csh -f
#
# ckmail - by Dave Brennan (brennan@rtp.dg.com)
#
# This is a shell script to indicate to the user his mailbox status.
# It assumes that the user uses elm as a mailer.
#
# This will be fouled up if either "From " or "Status: " appear at the
# beginning of a non-header line.
#
if ("$MAIL" == "") then
echo "Sorry. $MAIL not defined."
exit
endif
# count the total number of messages:
set total = `grep "^From " $MAIL | wc | cut -c5-7`
# count the number seen by elm:
set seen = `grep "^Status: " $MAIL | wc | cut -c5-7`
# count the number read:
set read = `grep "^Status: R" $MAIL | wc | cut -c5-7`
# count the number unseen by the user
set unseen = `grep "^Status: O" $MAIL | wc | cut -c5-7`
# so new messages =
@ new = $total - $seen
# build display strings
set c1 = ""
set c2 = ""
if ( $new != 0 ) then
set new = "$new new"
set c1 = ", "
else
set new = ""
endif
if ( $unseen != 0 ) then
set unseen = "$unseen unseen"
set c2 = ", "
else
set unseen = ""
endif
if ( $read != 0 ) then
set read = " $read old"
else
set read = ""
if ( "$c2" == ", " ) then
set c2 = ""
else
set c1 = ""
endif
endif
# stupid, stupid csh...
set mail = $MAIL
set mbox = $mail:t
# here's the deal:
if ( $total != 0 ) then
echo Mailbox $mbox':' $new$c1$unseen$c2$read messages.
else
echo Mailbox $mbox':' empty.
endif
--
_________
Dave Brennan, User Interfaces, Data General Corp. / brennan@dg-rtp.dg.com
Research Triangle Park, North Carolina, 27709 / ...mcnc!rti!dg-rtp!brennan
Hm: (919) 460-5725 Wk: (919) 248-6330 _________/ dave_brennan@rpitsmts.bitnetgupta@ux1.cso.uiuc.edu (04/14/90)
> # count the total number of messages: > set total = `grep "^From " $MAIL | wc | cut -c5-7` > # count the number seen by elm: > set seen = `grep "^Status: " $MAIL | wc | cut -c5-7` > # count the number read: > set read = `grep "^Status: R" $MAIL | wc | cut -c5-7` > # count the number unseen by the user > set unseen = `grep "^Status: O" $MAIL | wc | cut -c5-7` I don't think BSD machines have cut. I simply got rid of the last pipe, tacked the -l option onto the end of the wc command, and it worked on BSD. Thanks for the script! Rohit ------------------------------------------------------------------------------- Internet: rohit@uiuc.edu UUCP: uunet!uiucuxc!ux1!gupta BITnet: GUPTA@UIUCVMD "Master's of Business - that's the lowest!" - Diner