[comp.os.vms] VMS Batch Queue Mail Answerer

cfchiesa@bsu-cs.UUCP (Christopher Chiesa) (04/30/88)

I recently posted an article stating the availability of an admittedly hacked-
together DCL command procedure that would "sit in the SYS$BATCH queue and peri-
odically answer your VMS Mail," and soliciting requests for a copy of the pro-
gram.

Eight of you responded, and I've made an attempt to e-mail each of you a copy
of the file, but two of your addresses didn't even make it out of MY machine,
and I wouldn't bat an eye if the rest of them eventually wind up back in my
mailbox either.  So, just to get it out to you ONE way or another, I'm posting
it here.  If you're not interested, hit 'n' now.

Chris Chiesa

================== Edit out this line and everything above it. =============

$ SET NOVER
$!
$!   BANSWER.COM
$!
$!   Batch-Queue VMS Mail Answerer, c. 1986 Chris Chiesa
$!
$!   This procedure is intended to execute in the SYS$BATCH queue, and answer
$!   one's new VMS Mail messages.  It logs the conditions it finds - i.e.
$!   "# messages to answer," "answered at (time)," etc. - while replying, and
$!   then re-submits itself to execute again later.
$!
$!   This file is freely posted to Usenet by the author, and may be modified
$!   to any degree by anyone who feels so inclined.  Comments, flames, and
$!   especially IMPROVEMENTS, may be sent to
$!
$!      UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!cfchiesa
$!             cfchiesa@bsu-cs.UUCP
$!
$!   Note: I am already aware that this thing is a HACK, not the best of pro-
$!   gramming style even in VMS.  But at the time I wrote it, I'd only been on
$!   VMS about six months or so, self-taught from online HELP files, at that.
$!
$!===========================================================================
$!
$!   I'll make an attempt to comment this.
$!
$!   First, the SET NOVER, believe it or not, is crucial to the detection of
$!   new messages.  Don't remove it, or, if you do, remember to put it back!
$!
$ IF F$SEARCH("SYS$LOGIN:AUTOANS.LOG") .NES. "" THEN GOTO LOGOK
$!
$!  Create log file if not already present
$!
$ OPEN/WRITE LOG SYS$LOGIN:AUTOANS.LOG
$ WRITE LOG "Batch Queue Mail-Answer Log, initialized ",F$CVTIME(,,"DATETIME")
$ CLOSE LOG
$!
$ LOGOK:
$ MSGCNT = 0
$!
$!  The MAIN HACK: detect new messages by searching MAIL.MAI indiscriminately
$!  for the string "NEWMAIL".  Information on the internal structure of the
$!  MAIL.MAI file would allow you to do this much more carefully.
$!
$ SEARCH/OUTPUT=SYS$LOGIN:BLAH.TXT BSU$USER_8:[00CFCHIES.MAIL]MAIL.MAI NEWMAIL
$ OPEN/READ/ERROR=NOMSGS NO SYS$LOGIN:BLAH.TXT
$!
$!  Another, lesser hack, to COUNT the results.  This is the part that gets
$!  screwed up if you take out the SET NOVER above.
$!
$ LOOP:
$ READ/ERROR=NOMORE NO LINE
$ FOUND:
$ MSGCNT = MSGCNT + 1
$ GOTO LOOP
$!
$ NOMORE:                                       ! All messages accounted for
$ CLOSE NO
$ OPEN/APPEND LOG SYS$LOGIN:AUTOANS.LOG         ! Log number of msgs found
$ WRITE LOG MSGCNT," messages at ",F$TIME()
$ CLOSE LOG
$!
$ REPLY:                                        ! Reply, IF there are msgs.
$ IF MSGCNT .LE. 0 THEN GOTO NOMSGS
$ DEFINE SYS$OUTPUT SYS$LOGIN:SCRATCH.FIL
$!
$!  NOTE: This procedure replies with a fixed text contained right here in this
$!    procedure itself.  To reply with YOUR text rather than MINE, perform the
$!    necessary editing between "REP" and "$ EOD" below.
$!
$ MAIL
$ DECK
READ/NEW
REP
 
Hi. I'm not able to answer mail right now.  But I've left my answering machine
(ANSWER.COM, actually) here to let you know that I got your message.  
I'm probably working on something right now, but I'll attend to your message 
when I get to a reasonable pausing point.  Thanks for writing!

     Xetwnk

$ EOD
$!
$ OPEN/APPEND LOG SYS$LOGIN:AUTOANS.LOG            ! Log the fact of the reply
$ WRITE LOG "Replied  ... ",F$TIME()
$ CLOSE LOG
$ DEASSIGN SYS$OUTPUT
$ MSGCNT = MSGCNT - 1                              ! Repeat for all messages
$ GOTO REPLY
$!
$ NOMSGS:                                          ! Here after processing msgs
$ DELETE/NOCON SYS$LOGIN:BLAH.TXT;*        ! delete temporary files
$ DELETE/NOCON SYS$LOGIN:SCRATCH.FIL;*
$!
$ OPEN/APPEND LOG SYS$LOGIN:AUTOANS.LOG            ! Log back-to-sleep time
$ WRITE LOG "Back to sleep ",F$TIME()
$ CLOSE LOG
$!
$!  This re-SUBMIT could be replaced with a WAIT if your system managers allow
$!  you to submit long-running batch jobs; MY major concern was to not leave
$!  any one job running long enough to attract attention.
$!
$!  Modify the interval HERE ---VVVVV as a Delta Time...
$!
$ SUBMIT/NOLOG/NONOTIFY/AFTER="+00:20" BSU$USER_8:[00CFCHIES.COMS]BANSWER.COM
$ EXIT
-- 
UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!cfchiesa 
cfchiesa@bsu-cs.UUCP