home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc072.zip / ckvker.scr < prev    next >
Internet Message Format  |  1988-08-16  |  7KB

  1. Date: Tue, 16 Sep 86 09:44:36 pdt
  2. From: varian!david@lll-crg.ARPA
  3. Subject: Using C-Kermit on VAX/VMS for mail spooling.
  4.  
  5. We use C Kermit (058) under VMS here.  I wrote some scripts that run kermit
  6. unattended in order to send mail from UNIX to VMS.
  7.  
  8. ::::::::::::::
  9. README
  10. ::::::::::::::
  11. 5/2/86
  12.  
  13. These files allow you to transfer mail from a UNIX system to a VMS
  14. system (or any other system running a kermit with advanced server
  15. functions -- specifically, the remote host command).
  16.  
  17. On our leaf machines (madvax and vaxwaller), create aliases in
  18. /usr/lib/aliases for all users that you wish to send mail to, and
  19. just route mail to the gateway machine (varian):
  20.     shnell:varian!shnell
  21.  
  22. On the gateway machine, create an alias in /usr/lib/aliases to pipe
  23. the standard input to a program (vmsspool) which will place the text
  24. in an individual file (named user.pid) and append kermit commands for
  25. sending the file and running "remote host mail" to a take script:
  26.  
  27.     shnell:"!/usr/local/lib/vms/vmsspool lds shnell"
  28.  
  29.     (first argument is vms system name; second argument is user name
  30.     on that VMS system)
  31.  
  32. /usr/lib/aliases is found on systems using sendmail and delivermail;
  33. if you do not have these, you could write a front-end
  34. shell script for your mail command, or create a special purpose vmsmail
  35. command.   It may be possible to set up your sendmail configuration file
  36. to handle something like user@site.vmsdomain to avoid creating aliases
  37. for every VMS user, but I don't know enough about sendmail to do this.
  38.  
  39. Sometime later, either invoked from crontab or from a modified version
  40. of vmsspool (for immediate transmission), the vmsdaemon is started:
  41.     /usr/local/lib/vms/vmsdaemon lds
  42.     (one argument -- VMS system name)
  43.  
  44. This will:
  45.     1) Check to see if anything has been spooled up (the take script
  46.        is non-empty)
  47.     2) Using a take script specific for that VMS system in
  48.         /usr/local/lib/vms:
  49.        Calls up the system
  50.        Logs on as a specific ordinary user
  51.        Starts kermit in server mode on the VMS system
  52.     3) Runs the take script generated by vmsspool:
  53.          for each mail message
  54.         send text file
  55.         run mail on VMS
  56.         delete the file on VMS
  57.         delete the file on UNIX
  58.     4) Run a take script to exit kermit and logoff.
  59.     5) Check return code from kermit; if failure, keep the take
  60.         script for future retry; else delete it.
  61.  
  62.     Unknown behavior -- the most common error I expect is failure
  63.     to connect or login, in which case the take script containing
  64.     "delete the file on UNIX" should not be run; if for some reason,
  65.     that script is run and the text files are deleted but kermit
  66.     returns an error code, then the take file will still be around
  67.     but the text files will be gone.
  68.  
  69. On the VMS machine, you will need:
  70.  
  71. 1) A robust version of kermit, with server functions (at least "receive"
  72. and "remote host").  I had problems using server mode with the BLISS-based
  73. kermit (v3.1(066)), so I ended using ckermit (v4C(058)); if you don't
  74. have a C compiler on your VMS machine, you should be able to obtain
  75. a hex file of an executable; I believe that DEC has lifted the restriction
  76. on distribution of binaries built with the C compiler.
  77.  
  78. (Hint: when I first tried C kermit on our VMS machine, I got garbage
  79. characters for a prompt; it turned out the terminal was set for even
  80. parity -- I changed it to none).
  81.  
  82. 2) A login account. This can be any ordinary user account, but VMS users
  83. who receive mail will see this name in the header, so it should be
  84. something descriptive.
  85.  
  86.  
  87. FUTURE:
  88. I have not yet implemented sending mail back from VMS to UNIX.
  89. My proposal is for the VMS user to reply to the login account which sent
  90. him the mail (reply in mail should work OK) and place a
  91.     To: unix_user
  92. in the text of his message.  When vmsdaemon calls up VMS from UNIX,
  93. it will (using script function of kermit) start up mail, extract all
  94. messages into one or more text files, get those files back to UNIX,
  95. and use a variant of recmail (a program supplied with bnews which will
  96. send mail according to "To:" lines in a file) to send mail to the
  97. appropriate user.   The main shortcoming of recmail is that it sends
  98. the entire message to all names on a "To:" line; we want to be able
  99. to break up multiple messages, and also to ignore "To:" lines that
  100. mention our VMS login.
  101.  
  102.  
  103.  
  104. ::::::::::::::
  105. vmsspool
  106. ::::::::::::::
  107. :
  108. # vmsspool:
  109. # This will spool up mail to send to a VMS site via kermit
  110. # It creates a file of send and remote host commands to be executed by
  111. #    the kermit take command.
  112. #
  113. # Usage:
  114. #    vmsspool VMSsystem VMSname
  115. #    Input is taken from standard input.
  116. # It may be invoked from /usr/lib/aliases:   user: | "spoolvms vsystem vuser"
  117.  
  118. DIR=/usr/spool/vms
  119. SCRIPT=$DIR/$1
  120. # VUSER = login name under VMS
  121. VUSER=$2
  122. # UFILE = name of data file under UNIX
  123. UFILE=$DIR/$VUSER.$$
  124. # VFILE = name of data file under VMS
  125. VFILE=$VUSER.TXT
  126.  
  127. cat > $UFILE
  128. echo "send $UFILE $VFILE" >> $SCRIPT
  129. echo "remote host mail $VFILE $VUSER" >> $SCRIPT
  130. echo "remote host delete $VFILE;1" >> $SCRIPT
  131. echo "! rm $UFILE" >> $SCRIPT
  132.  
  133.  
  134.  
  135. ::::::::::::::
  136. vmsdaemon
  137. ::::::::::::::
  138. :
  139. # vmsdaemon - connect to a VMS system, start up a kermit server,
  140. #    execute the kermit commands in a specified take script
  141. #
  142. # Usage:    vmsdaemon VMS-system-name
  143. # (Note: the VMS system name will have the same name as the take-script)
  144. #
  145. # You will probably want to execute this from crontab or from vmsspool
  146. #  (if you want immediate transmission).
  147. #
  148.  
  149. DIR=/usr/spool/vms
  150. LIB=/usr/local/lib/vms
  151. VSYSTEM=$1
  152. SCRIPT=$DIR/$VSYSTEM
  153. WORKSCRIPT=$DIR/$VSYSTEM.work
  154. CONNECT=$LIB/$VSYSTEM
  155. FINISH=$LIB/finish
  156. PORT=/dev/tty00
  157. SPEED=1200
  158. KERMIT=/usr/local/bin/kermit
  159.  
  160. if test $# -ne 1
  161. then
  162.     echo "Usage: vmsdaemon VMS-system-name"
  163.     exit 1
  164. fi
  165.  
  166. if test -s $WORKSCRIPT
  167. then
  168.     echo "Work script already exists"
  169.     exit 1
  170. fi
  171.  
  172. if test -s $SCRIPT
  173. then
  174.     cp $SCRIPT $WORKSCRIPT
  175.     echo -n > $SCRIPT
  176. else
  177.     echo "No work"
  178.     exit 0
  179. fi
  180.  
  181. $KERMIT -l $PORT -b $SPEED << EOF
  182. take $CONNECT
  183. take $WORKSCRIPT
  184. take $FINISH
  185. EOF
  186.  
  187. if test $? -eq 0
  188. then
  189.     echo "Succeeded"
  190.     rm $WORKSCRIPT
  191.     exit 0
  192. else
  193.     echo "Failed"
  194.     cat $WORKSCRIPT >> $SCRIPT
  195.     rm $WORKSCRIPT
  196.     exit 1
  197. fi
  198.  
  199.  
  200.  
  201.  
  202. ::::::::::::::
  203. lds
  204. ::::::::::::::
  205. log trans
  206. set modem-dialer hayes
  207. dial PHONE-NUMBER
  208. script name:--name:--name: ~d~d~dVMS-LOGIN ssword: VMS-PASSWORD ~w45$--$ \
  209. kermit ermit>--ermit> server
  210.  
  211.  
  212.  
  213. ::::::::::::::
  214. finish
  215. ::::::::::::::
  216. bye
  217. script $--$ lo
  218.  
  219. -------
  220.