taylor@limbo.Intuitive.Com (Dave Taylor) (12/22/89)
This is a cute little shell script I hacked up to allow me to have some minimal idea what's going on with some of the remote accounts that I have, but don't necessarily want to log in to with any frequency to check. The script expects to be run from a cron or crontab file. Enjoy and happy end of 1989 to y'all! -- Dave Taylor Intuitive Systems Mountain View, California taylor@limbo.intuitive.com or {uunet!}{decwrl,apple}!limbo!taylor --- Attachment: #!/bin/sh # # DistantBiff - A script to aid users in keeping track of mail # they might receive on remote computer accounts. # # Author: Dave Taylor, Intuitive Systems <taylor@intuitive.com> # # Use by adding an occasional invocation of this script to the # cron program, perhaps nightly, or once a week... # LOCALIZE the following USERNAME=taylor SEND_MAIL_TO=taylor@Intuitive.Com # stuff you might need to change for BSD, local configuration, etc. HOMEDIR=/users/$USERNAME MAILBOX=/usr/mail/$USERNAME mail=/usr/bin/mailx # should understand '-s' flag for subject from="/usr/local/bin/from -n" # and stuff you should probably leave alone... host=`hostname` oldfile=".last.from" # these newfile=".new.from" # live in newmsgs=".new.msgs" # users home changes="none" # first step: move us into the home directory cd $HOMEDIR # now let's get a summary of the current mailbox state $from $MAILBOX > $newfile # armed with this, let's now figure out what's changed... if [ ! -f $oldfile ] ; then # first time we've run! changes="all" else diff $newfile $oldfile > $newmsgs # New mail? if [ "`head $newmsgs`" != "" ] ; then # MMmmmm...YES! changes="new" fi fi # now let's send a summary based on what changes there are. case $changes in # if it's new, we'll get just the stuff that shows up in new but # not old (to avoid reporting deleted messages, which would be in # old but not new) (cute, eh?), and strip off the '<' from diff new) cat $newmsgs | grep '^<' | sed 's/^< //' | \ $mail -s "New messages on $host" $SEND_MAIL_TO ;; # otherwise, just send the output of the 'from' command! all) $mail -s "New mail on $host" $SEND_MAIL_TO < $newfile ;; # unless nothing has changed... *) ;; # nothing to do since no changes! esac # some final cleanup... /bin/mv $newfile $oldfile # update for next time /bin/rm -f $newmsgs # and discard this # and we're done! exit 0 # -- end of script