home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / cu / cunix.scr < prev    next >
Text File  |  2020-01-01  |  8KB  |  257 lines

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