home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskscripts / rolmunix.kds < prev    next >
Text File  |  2020-01-01  |  8KB  |  261 lines

  1. ; CUNIX.SCR
  2. ;
  3. ; Christine M. Gianone, CUCCA/AcIS, October 1991
  4. ;
  5. ; An MS-DOS Kermit script for easy access to Columbia University's
  6. ; CUNIX systems.  It navigates through ROLMphone and terminal server
  7. ; and logs the user in.
  8. ;
  9. ; You can run this script from within Kermit by typing TAKE CUNIX.SCR,
  10. ; but it is designed for more convenient use by running Batch files
  11. ; from the DOS command line, for example CUNIXA.BAT
  12. ;
  13. ;   CUNIXA myuserid
  14. ;
  15. ; userid and password can be given on the DOS command
  16. ; line, for example:
  17. ;
  18. ;   C:\>cunixa myuserid mypassword
  19. ;
  20. ; The "cunixa" DOS command requires the following CUNIXA.BAT file to
  21. ; reside in the user's PATH:
  22. ;
  23. ;   @echo off
  24. ;   kermit def userid %1, def passwd %2, def host cunixa, take cunix.scr, stay
  25. ;
  26. ; CUNIX.SCR prompts for user ID and password if these are not 
  27. ; already defined, then connects through the CBX, automatically detecting 
  28. ; either a regular DCM phone or a 244PC, and logs in to the host.
  29. ;
  30. ; IMPORTANT: CUNIX.SCR assumes user's shell prompt is "$ " or "% ".
  31. ;
  32. ; Requires MS-DOS Kermit 3.11 or later.
  33.  
  34. if not < version 311 goto OK
  35. echo Sorry, version 3.11 or later of MS-DOS Kermit is required.
  36. stop
  37.  
  38. :OK
  39.  
  40. ;;; NOTE: If your UNIX system prompt is not "$ " or "% ",
  41. ;;; you must define the "myprompt" variable to say what it is, as in the
  42. ;;; following commented-out command for a "cunixa: " prompt:
  43. ;
  44. ; define myprompt {cunixa: }
  45.  
  46. ; Macro to issue an error message and stop.
  47. ;
  48. define errstop echo \%1, hangup, stop
  49.  
  50. ; Define GETOUT macro to log out from UNIX, hang up, and exit Kermit.
  51. ;
  52. define getout out \13,-
  53.  inp 8 \m(prompt),-
  54.  if succ out exit \59 exit\13,-
  55.  hangup,-
  56.  exit
  57.  
  58. set key \2320 {\Kgetout}        ; Assign GETOUT macro to Alt-Q. 
  59.  
  60. ; Action starts here
  61. ;
  62. if def passwd cls            ; for security...
  63. def \%9                    ; "Thank you" flag.
  64.  
  65. if def host goto ASKUID
  66. :XHOST
  67. ask \%8 {Which CUNIX system: }
  68. if not def \%8 goto XHOST
  69. assign host \%8
  70. def \%9 Thank you.
  71.  
  72. :ASKUID
  73. if def userid goto askpw
  74. :XUID
  75. ask \%8 {Please type your user ID, then press the Enter key: }
  76. if not def \%8 goto XUID
  77. assign userid \%8
  78. def \%9 Thank you.
  79.  
  80. :ASKPW
  81. if def passwd goto thanks
  82. :XPWD
  83. askq \%8 -
  84.   {Please type your password (it won't echo), then press the Enter key: }
  85. if not def \%8 goto XPWD
  86. assign passwd \%8
  87. def \%9 Thank you.
  88.  
  89. :THANKS
  90. def \%8                ; Erase password from memory
  91. if def \%9 echo \%9        ; Be polite
  92. def \%9
  93. echo
  94.  
  95. ; Communication and script settings
  96. ;
  97. set parity none            ; Don't use parity.
  98. set display 7            ; But don't display it either.
  99. set flow xon/xoff        ; Use Xon/Xoff flow control.
  100. set handsh none            ; No handshake.
  101. set duplex full            ; Full duplex, remote echo.
  102. set input timeout proceed    ; This enables IF SUCCESS and IF FAILURE.
  103. set input case ignore        ; Don't care about alphabetic case.
  104. hangup                ; Hang up any current data connection. 
  105. pause
  106.  
  107. ; Try 3 times to get Rolmphone's attention.
  108. ;
  109. :LOOP
  110. output \13            ; Output a carriage return.
  111. :CBX                ; Assume DCM with CALL, DISPLAY OR MODIFY?
  112. input 6 MODIFY?            ; Look for CBX prompt.
  113. if failure goto RP244PC        ; If not found, go try 244PC.
  114. echo \13CBX dialing...        ; It's the CBX, tell the user.
  115. output CALL CUNIX\13        ; Dial CUNIX.
  116. input 30 COMPLETE        ; Get CALL COMPLETE message
  117. if failure errstop -
  118.   {Sorry, the CUNIX terminal server does not answer.  Please try again later.}
  119. goto good            ; Got connected, go login
  120.  
  121. :RP244PC                        ; Let's see if it's a 244PC
  122. output \13AT\13            ; Give the Hayes modem AT command
  123. input 5 OK            ; Look for Hayes OK response.
  124. if failure goto RETRY        ; Not found, try again.
  125. echo 244PC dialing...        ; It's 244PC, tell the user.
  126. output ATDT[CUNIX]\13        ; Make a data call to "[CUNIX]".
  127. input 30 CONNECT                ; Look for modem's confirmation.
  128. if success goto GOOD
  129.  
  130. :RETRY
  131. if count goto LOOP
  132.  
  133. ; Get here when there is no communication after 3 tries.
  134. ;
  135. echo
  136. echo {  Sorry, I can't seem to communicate with your ROLMphone.}
  137. echo {  Your port is \v(port), your speed is \v(speed).}
  138. echo {  If these parameters are not correct, use Kermit's SET PORT}
  139. echo {  and SET SPEED commands to correct them and try again.}
  140. echo {  Otherwise, please check the data cable between your PC}
  141. echo {  and the ROLMphone and try again.}
  142. echo
  143. hangup
  144. stop
  145.  
  146. :GOOD                           ; We got through, one way or the other.
  147. ;
  148. ; Send carriage returns for speed recognition.  Try up to 7 times
  149. ; to get terminal server prompt.
  150. ;
  151. pause
  152. set count 7
  153.  
  154. :AGAIN
  155. output \13
  156. input 1 >
  157. if success goto TSPROMPT    ; If found, proceed with login process,
  158. if count goto again        ; otherwise continue the loop.
  159. errstp {Failure to get terminal server prompt, try again later.}
  160.  
  161. :TSPROMPT
  162. ;
  163. ; Got terminal server prompt, select host, and wait for login: prompt.
  164. ;
  165. output \m(host)\13        ; Ask for the desired host.
  166. input 20 login:
  167. if fail errstop {Failure to get login prompt, please try again later.}
  168.  
  169. :LOGIN
  170. ;
  171. ; Got "login:" prompt, send user ID and look for "Password:" prompt.
  172. ;
  173. output \m(userid)\13        ; Send user ID, followed by CR.
  174. input 20 Password:        ; Wait up to 5 seconds for "Password:" prompt.
  175. if fail errstop {Failure to get password prompt, please try again later.}
  176.  
  177. ; Send user's password, then wait for shell prompt.
  178. ;
  179. output \m(passwd)\13        ; Send password.
  180. define passwd            ; Erase from memory.
  181.  
  182. ; Now try to get the shell prompt.
  183. ;
  184. if not def myprompt goto GUESS    ; No custom prompt, must guess.
  185.  
  186. assig prompt \m(myprompt)    ; Custom prompt defined.
  187. input 60 \m(prompt)        ; Look for it.
  188. if success goto TERM        ; Got it.  Go start application.
  189. output \26            ; Didn't get it, try to Ctrl-Z out of notes.
  190. input 10 \m(prompt)        ; Look for prompt again.
  191. if success goto TERM        ; Got it...
  192. output \26            ; Didn't get it, try one more Ctrl-Z.
  193. input 10 \m(prompt)        ; Look again.
  194. if success goto TERM        ; Got it...
  195. errstop {Sorry, the system is too busy.  Please try again later.}
  196.  
  197. :GUESS
  198. ;
  199. ; No custom prompt.  Look for standard sh, ksh, or csh prompt.
  200. ;
  201. input 60 \13\10$\32        ; Look for "$ " (ksh or sh).
  202. if success goto TERMD        ; Got it.  Go start application.
  203. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  204. if success goto TERMP
  205. output \26            ; Didn't get it, try to Ctrl-Z out of notes.
  206. input 10 \13\10$\32        ; Look for prompt again.
  207. if success goto TERMD        ; Got it...
  208. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  209. if success goto TERMP
  210. output \26            ; Didn't get it, try one more Ctrl-Z.
  211. input 10 \13\10$\32        ; Look again.
  212. if success goto TERMD        ; Got it...
  213. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  214. if success goto TERMP
  215. errstop {Sorry, the system is too busy.  Please try again later.}
  216.  
  217. :TERMD
  218. assig prompt \13\10$\32
  219. goto TERM
  220. :TERMP
  221. assig prompt \13\10%\32
  222. :TERM
  223. ;
  224. ; User is logged in and has system prompt.  Now set terminal type.
  225. ; The tset command should work for any shell.
  226. ;
  227. set input echo off
  228. set terminal type vt320
  229. output eval `tset -sQ vt300` \59 echo Hi!\13
  230. input 30 \m(prompt)
  231.  
  232. echo
  233. echo You are now logged in to \m(host).
  234. echo Use Alt-x to get back to Kermit.
  235. echo Use Alt-q to log out from \m(host) and return to DOS.
  236. echo Press any key to start...
  237. echo
  238. pause 9999            ; Wait for them to press a key.
  239. output \13            ; Send a carriage return.
  240. connect                ; Begin terminal emulation.
  241.  
  242. ; If they escaped back, check the carrier detect signal to see if they
  243. ; logged out, issue appropriate messages in each case.
  244. ;
  245. wait 1 CD
  246. if succ goto WARN
  247. echo
  248. echo {  Your connection to \m(host) is broken.}
  249. echo {  Type EXIT (then Enter) to leave Kermit and go back to DOS.}
  250. stop
  251.  
  252. :WARN
  253. echo
  254. echo Warning: back at PC, but connection to \m(host) might still be active.
  255. echo
  256. echo {  Type CONNECT (then press the Enter key) to go back to \m(host).}
  257. echo {  Type HANGUP (then Enter) to cancel your \m(host) session.}
  258. echo {  Type EXIT (then Enter) to leave Kermit and go back to DOS.}
  259. echo
  260. stop
  261.