[comp.mail.mh] mh and vacation?

ben@sybase.com (ben ullrich) (11/27/90)

i'm going away from work for a long time, and would like to set up my mailer to
return mail to senders announcing my inability to answer.  most folks do this
with ucb's vacation program, but i'd like to use MH to do it, so i can include
my usual header info, and inc the mail as it comes in, etc.

i tried doing this a while ago using slocal, and it never worked.  does anyone
have any instructions on how to get slocal or some other mh component to
incorporate mail, construct a reply, and send it automatically?

thanks,


..ben
------
ben ullrich			 only i do the talking here -- not my employer.
ben@sybase.com			       {pyramid,pacbell,sun,lll-tis}!sybase!ben
	       "why waste time learning when ignorance is instantaneous?"-hobbes

jerry@ora.ora.COM (Jerry Peek) (11/27/90)

On 27 Nov 90 00:07:42, ben ullrich <mtxinu!sybase!ben@sybase.com> wrote:
> i'm going away from work for a long time, and would like to set up my mailer 
> to
> return mail to senders announcing my inability to answer.  most folks do this
> with ucb's vacation program, but i'd like to use MH to do it, so i can include
> my usual header info, and inc the mail as it comes in, etc.
> 
> i tried doing this a while ago using slocal, and it never worked.  does anyone
> have any instructions on how to get slocal or some other mh component to
> incorporate mail, construct a reply, and send it automatically?

slocal can do a lot, but it still can't replace the shell.  You might
want to write a shell script that's run by cron(1) (if your UNIX has
personal crontabs) or at(1).  Run it once a day, late at night, to
inc your new mail, sort it, reply to the ones that need replies, etc.

For instance, here's a special-purpose script I wrote called 'autoinc'.  It:
* Checks my disk quota to be sure I have room to 'inc' the mail
  (and sends mail to another address to complain if I don't).
* inc's the mail
* Uses a scan format string to grab the 'sender' field and message
  number of each message.
* Sends the scan output into a 'while' loop that refiles some messages
  from the inbox.
This isn't especially bulletproof, but it's been running for a while
and seems to do fine.  Maybe it'll give you a start... you could hack
the 'while' loop to make and check some kind of database of who's gotten
an "on-vacation" reply.

--Jerry Peek, jerry@ora.com

---------------------------------------------------------------------------

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by rodan.acs.syr.edu!jdpeek on Tue Nov 27 05:43:06 EST 1990
# Contents:  autoinc
 
echo extracting - autoinc
sed 's/^X//' > "autoinc" <<'X//E*O*F autoinc//'
X#! /bin/sh
X###	autoinc - Incorporate new mail; refile most stuff in inbox automatically
X###	Usage: autoinc
X
X# TABSTOPS ARE SET AT 4 IN THIS CODE
X
Xdf=/bin/df
Xerror=xxxx@xxxx.bitnet,xxxx@ora.com	# WHERE TO MAIL ERRORS
Xexpr=/bin/expr
Xgrep=/bin/grep
Xmailer=/usr/ucb/mail
Xmargin=300				# HOW MANY EXTRA KBYTES WE NEED
Xmh=/usr/local/mh			# WHERE MH PROGRAMS LIVE
Xquota=/usr/ucb/quota
Xsed=/bin/sed
Xtr=/bin/tr
X
X# GET NAME OF FILESYSTEM WITH HOME DIRECTORY FROM LINES LIKE
X# THIS.  TAKE LAST WORD STARTING WITH A SLASH ON SECOND LINE:
X# Filesystem            kbytes    used   avail capacity  Mounted on
X# precious:/u1          842171  442588  315365    58%    /u1
Xhomedir="`$df ${HOME?} | $sed -n '2s@.*\(/[^/]*\)$@\1@p'`"
X
X# GET QUOTA VALUES.  USE sed TO GRAB LINE
X# THAT STARTS WITH ${homedir} AND PUT THE FIRST TWO NUMBERS ON
X# THE LINE INTO SHELL VARIABLES:
Xeval `$quota -v |
X$sed -n "s@^${homedir} *\([0-9][0-9]*\) *\([0-9][0-9]*\).*@used=\1 total=\2@p"`
X
X# PUT x IN $1, NUMBER OF KBYTES IN $2, MAILBOX FILENAME IN $3:
Xset x `/bin/ls -s /usr/spool/mail/$USER`
Xwouldbe="`$expr $used + $2 + $margin`"
Xif [ $wouldbe -ge $total ]
Xthen
X
X	echo "already used $used kytes, incoming mail is $2 kbytes, quota is $total." |
X	$mailer -s "ERROR -- no room to incorporate new mail!  Clean up files now!" $error
X	exit
Xfi
X
X# FILTER inc OUTPUT THROUGH grep, PUT LEFTOVERS BACK ONTO STDERR.
X# IF inc RETURNS NON-ZERO, EXIT.
X$mh/inc 2>&1 | $grep -v '^inc: no mail to incorporate' 1>&2  || exit
X
Xset -e	# IF ANY ERRORS FROM NOW ON, EXIT
X
X# SCAN MESSAGES IN inbox.  GET MESSAGE NUMBER AND SENDER (LIKE "ENVBEH-L")
X# TURN UPPER TO LOWER CASE.  THEN FEED TO STDIN OF LOOP.
X# INSIDE LOOP, REFILE MESSAGES WE KNOW HOW TO HANDLE; LEAVE OTHERS:
X$mh/scan +inbox -format '%(msg) %(mbox{sender}) %(mbox{from})' |
X$tr A-Z a-z |
Xwhile read msg sender from
Xdo
X	case "$sender" in
X	math-l|methods|music-ed|philosop|physic-l|physics)
X		$mh/refile $msg +$sender
X		continue
X		;;
X	polcomm|poli-sci|psych-l|religion|rhetoric|scifraud|socorg-k)
X		$mh/refile $msg +$sender
X		continue
X		;;
X	stlhe-l|theatre|words-l)
X		$mh/refile $msg +$sender
X		continue
X		;;
X	esac
X	case "$from" in
X	music-research)
X		$mh/refile $msg +music
X		continue
X		;;
X	esac
Xdone
X//E*O*F autoinc//
chmod u=rwx,g=rx,o=rx autoinc
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      74     323    2204 /var/tmp/autoinc
!!!
wc  autoinc | sed 's/^X//' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0