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

  1. ; CUNIX.SCR
  2. ;
  3. ; Christine M. Gianone, CUCCA/AcIS, October 1991.
  4. ; Modified March 1994 for new access procedures, fdc.
  5. ;
  6. ; An MS-DOS Kermit script for easy access to Columbia University's
  7. ; CUNIXF system.  It navigates through ROLMphone and terminal server
  8. ; and logs the user in.  In addition, if the variable APPL is 
  9. ; defined, this script will start up an application automatically.
  10. ; For example, if APPL is defined to be EMAIL, MM is started.
  11. ;
  12. ; You can run this script from within Kermit by typing TAKE CUNIX.SCR,
  13. ; but it is designed for more convenient use by running Batch files
  14. ; from the DOS command line, for example EMAIL.BAT:
  15. ;
  16. ;   EMAIL myuserid
  17. ;
  18. ; In this example, e-mail userid and password can be given
  19. ; on the DOS command line, for example:
  20. ;
  21. ;   C:\>email myuserid mypassword
  22. ;
  23. ; The "email" DOS command requires the following EMAIL.BAT file to
  24. ; reside in the user's PATH:
  25. ;
  26. ;   @echo off
  27. ;   kermit def userid %1, def passwd %2, def appl email, take CUNIX.scr, stay
  28. ;
  29. ; CUNIX.SCR prompts for CUNIXF (INFO) ID and password if these are not 
  30. ; already defined, then connects through the CBX, automatically detecting 
  31. ; either a regular DCM phone or a 244PC, logs in to CUNIXF.  If the EMAIL
  32. ; application is selected, CUNIX.SCR issues brief instructions, then starts
  33. ; MM, and a function is assigned to Alt-Q to get out of MM, log out, and
  34. ; hang up the data connection.
  35. ;
  36. ; IMPORTANT: CUNIX.SCR assumes user's shell prompt is "$ " or "% ".
  37. ;
  38. ; Requires MS-DOS Kermit 3.11 or later.
  39.  
  40. if not < version 311 goto OK
  41. echo Sorry, version 3.11 or later of MS-DOS Kermit is required.
  42. stop
  43.  
  44. :OK
  45.  
  46. ;;; NOTE: If your CUNIXF system prompt is not "$ " or "% ",
  47. ;;; you must define the "myprompt" variable to say what it is, as in the
  48. ;;; following commented-out command for a "cunixf: " prompt:
  49. ;
  50. ; define myprompt {cunixf: }
  51.  
  52. ; Define GETOUT macro to log out from UNIX, hang up, and exit Kermit.
  53. ;
  54. define getout out \13,-
  55.  inp 8 \m(prompt),-
  56.  if succ out exit \59 exit\13,-
  57.  hangup,-
  58.  exit
  59.  
  60. set key \2320 {\Kgetout}        ; Assign GETOUT macro to Alt-Q. 
  61.  
  62. ; Define ERRSTOP macro to issue an error message and stop.
  63. ;
  64. define errstop echo \%1, hangup, stop
  65.  
  66. ; Action starts here
  67. ; If they typed their password on the DOS command line,
  68. ; clear the screen now.
  69. ;
  70. if def passwd cls            ; for security...
  71. def \%9                    ; "Thank you" flag.
  72. if def userid goto askpw
  73.  
  74. :XUID
  75. ;
  76. ; User ID wasn't specified on command line, so prompt for it.
  77. ;
  78. ask \%8 {Please type your e-mail user ID, then press the Enter key: }
  79. if not def \%8 goto XUID
  80. assign userid \%8
  81. def \%9 Thank you.
  82.  
  83. :ASKPW
  84. if def passwd goto thanks
  85. :XPWD
  86. ;
  87. ; Password wasn't specified on command line, so prompt for it.
  88. ;
  89. askq \%8 -
  90.   {Please type your password (it won't echo), then press the Enter key: }
  91. if not def \%8 goto XPWD
  92. assign passwd \%8
  93. def \%9 Thank you.
  94.  
  95. :THANKS
  96. def \%8                ; Erase password from memory
  97. if def \%9 echo \%9        ; Be polite
  98. def \%9
  99. echo
  100.  
  101. ; Communication and script settings
  102. ;
  103. ; Note: we don't override any settings from the user's MSKERMIT.INI file
  104. ; that are not necessary for this script.  User's speed, key settings,
  105. ; screen colors, etc, remain in effect.
  106. ;
  107. set parity none            ; Don't use parity.
  108. set display 7            ; But don't display it either.
  109. set flow xon/xoff        ; Use Xon/Xoff flow control.
  110. set handsh none            ; No handshake.
  111. set duplex full            ; Full duplex, remote echo.
  112. set input timeout proceed    ; This enables IF SUCCESS and IF FAILURE.
  113. set input case ignore        ; Don't care about alphabetic case.
  114. hangup                ; Hang up any current data connection. 
  115. pause
  116.  
  117. ; Try 3 times to get Rolmphone's attention.
  118. ;
  119. :LOOP
  120. output \13            ; Output a carriage return.
  121. :CBX                ; Assume DCM with CALL, DISPLAY OR MODIFY?
  122. input 6 MODIFY?            ; Look for CBX prompt.
  123. if failure goto RP244PC        ; If not found, go try 244PC.
  124. echo \13CBX dialing...        ; It's the CBX, tell the user.
  125. output CALL CUNIX\13        ; Dial CUNIX.
  126. input 30 COMPLETE        ; Get CALL COMPLETE message
  127. if failure errstop -
  128.   {Sorry, CUNIX does not answer.  Please try again later.}
  129. goto good            ; Got connected, go login
  130.  
  131. :RP244PC                        ; Let's see if it's a 244PC
  132. output \13AT\13            ; Give the Hayes modem AT command
  133. input 5 OK            ; Look for Hayes OK response.
  134. if failure goto RETRY        ; Not found, try again.
  135. echo 244PC dialing...        ; It's 244PC, tell the user.
  136. output ATDT[CUNIX]\13        ; Make a data call to "[CUNIX]".
  137. input 30 CONNECT                ; Look for modem's confirmation.
  138. if success goto GOOD
  139.  
  140. :RETRY
  141. if count goto LOOP
  142.  
  143. ; Get here when there is no communication after 3 tries.
  144. ;
  145. echo
  146. echo {  Sorry, I can't seem to communicate with your ROLMphone.}
  147. echo {  Your port is \v(port), your speed is \v(speed).}
  148. echo {  If these parameters are not correct, use Kermit's SET PORT}
  149. echo {  and SET SPEED commands to correct them and try again.}
  150. echo {  Otherwise, please check the data cable between your PC}
  151. echo {  and the ROLMphone and try again.}
  152. echo
  153. hangup
  154. stop
  155.  
  156. :GOOD
  157. ; We got through, one way or the other.
  158. ; Send carriage returns for speed recognition.
  159. ; Try up to 5 times to get Info terminal server prompt, "blah>".
  160. ;
  161. set count 5            ; Loop counter.
  162.  
  163. :AGAIN
  164. output \13            ; Send CR for speed recognition.
  165. input 3 >            ; Look for prompt.
  166. if success goto INFO        ; If found, proceed with login process,
  167. if count goto again        ; otherwise continue the loop.
  168. errstp {Failure to get terminal server prompt, please try again later.}
  169.  
  170. :INFO
  171. ;
  172. ; Got terminal server prompt, select cunix and wait for login prompt.
  173. ;
  174. output cunix\13
  175. input 20 login:
  176. if fail errstop {Failure to get login prompt, please try again later.}
  177.  
  178. :LOGIN
  179. ;
  180. ; Got "login:" prompt, send user ID and look for "Password:" prompt.
  181. ;
  182. output \m(userid)\13        ; Send user ID, followed by CR.
  183. input 20 Password:        ; Wait up to 5 seconds for "Password:" prompt.
  184. if fail errstop {Failure to get password prompt, please try again later.}
  185.  
  186. ; Send user's password, then wait for shell prompt.
  187. ; Here we must figure out whether it is "$ " or "% ".
  188. ; If it is anything else, such as "cunixa:", that must be
  189. ; predefined (see top of this file).
  190. ;
  191. output \m(passwd)\13        ; Send password.
  192. define passwd            ; Erase from memory.
  193.  
  194. ; Now try to get the shell prompt.
  195. ;
  196. if not def myprompt goto GUESS    ; No custom prompt, must guess.
  197.  
  198. assig prompt \m(myprompt)    ; Custom prompt defined.
  199. input 60 \m(prompt)        ; Look for it.
  200. if success goto TERM        ; Got it.  Go start application.
  201. output \26            ; Didn't get it, try to Ctrl-Z out of notes.
  202. input 10 \m(prompt)        ; Look for prompt again.
  203. if success goto TERM        ; Got it...
  204. output \26            ; Didn't get it, try one more Ctrl-Z.
  205. input 10 \m(prompt)        ; Look again.
  206. if success goto TERM        ; Got it...
  207. errstop {Sorry, the system is too busy.  Please try again later.}
  208.  
  209. :GUESS
  210. ;
  211. ; No custom prompt.  Look for standard sh, ksh, or csh prompt.
  212. ;
  213. input 60 \13\10$\32        ; Look for "$ " (ksh or sh).
  214. if success goto TERMD        ; Got it.  Go start application.
  215. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  216. if success goto TERMP
  217. output \26            ; Didn't get it, try to Ctrl-Z out of notes.
  218. input 10 \13\10$\32        ; Look for prompt again.
  219. if success goto TERMD        ; Got it...
  220. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  221. if success goto TERMP
  222. output \26            ; Didn't get it, try one more Ctrl-Z.
  223. input 10 \13\10$\32        ; Look again.
  224. if success goto TERMD        ; Got it...
  225. reinput 1 \13\10%\32        ; Try for "% " C-Shell prompt.
  226. if success goto TERMP
  227. errstop {Sorry, the system is too busy.  Please try again later.}
  228.  
  229. :TERMD
  230. assig prompt \13\10$\32
  231. goto TERM
  232. :TERMP
  233. assig prompt \13\10%\32
  234. :TERM
  235. ;
  236. ; User is logged in and has system prompt.  Now set terminal type.
  237. ; The tset command should work for any shell.
  238. ;
  239. set input echo off
  240. set terminal type vt320
  241. output eval `tset -sQ vt300` \59 echo Hi!\13
  242. input 30 \m(prompt)
  243.  
  244. ; Define top and bottom box border
  245. ;
  246. assign \%9 \205\205\205\205\205\205\205\205\205\205\205\205\205\205\205\205
  247. assign \%9 \%9\%9\%9\%9\205\205\205
  248.  
  249. ; Now start an application if one has been selected.
  250. ;
  251. if not def appl goto NOAPP        ; No application, just CONNECT.
  252.  
  253. ; Table of known applications.
  254. ; Add more below.
  255. ;
  256. if eq \m(appl) email goto EMAIL
  257. if eq \m(appl) info goto NOAPP
  258. if eq \m(appl) calendar goto CAL
  259. echo Unknown application: \m(appl).
  260. goto noapp
  261.  
  262. :EMAIL
  263. ;
  264. ; Redefine EXIT macro to get out of MM, then log out, then hang up.
  265. ;
  266. define getout out \3,-
  267. inp 5 MM\63 [y/n]\32,-
  268. if succ goto xa,-
  269. out \3,-
  270. inp 5 MM\63 [y/n]\32,-
  271. if fail goto xx,-
  272. :XA,-
  273. out y\13,-
  274. inp 5 ing\63 [y/n]\32,-
  275. if fail goto xx,-
  276. out y\13,-
  277. :XX,-
  278. out \13,-
  279. inp 8 \m(prompt),-
  280. if succ out exit \59 exit\13,-
  281. hangup,-
  282. exit
  283.  
  284.  
  285. ; Start up MM and give instructions, packaged in a nice-looking box.
  286. ;
  287. ec \201\%9\187
  288. ec \186                                                                   \186
  289. ec \186 You will now be connected to the E-Mail program, MM.              \186
  290. ec \186   Type a question mark for a list of commands.                    \186
  291. ec \186   Type HELP followed by <Enter> for a help message.               \186
  292. ec \186 When you are finished with your MM session, use Alt-q to logout.  \186
  293. ec \186 Use Alt-x to return to Kermit without logging out.                \186
  294. ec \186                                                                   \186
  295. ec \200\%9\188
  296. echo
  297. echo Press any key to start your MM session...
  298. echo
  299. pause 9999            ; Wait for them to type something.
  300.  
  301. ; Here we go...
  302. ;
  303. set terminal clear        ; Clear terminal screen.
  304. output mm\13            ; Start MM.
  305. connect                         ; Start terminal emulation.
  306. ;
  307. ; If they escaped back, check the carrier detect signal to see if they
  308. ; logged out, issue appropriate messages in each case.
  309. ;
  310. wait 1 CD
  311. if succ goto WARN
  312. echo
  313. ec \201\%9\187
  314. ec \186                                                                   \186
  315. ec \186  Your connection to the E-Mail system is broken.                  \186
  316. ec \186  Type EXIT (then Enter) to leave Kermit and go back to DOS.       \186
  317. ec \186                                                                   \186
  318. ec \200\%9\188
  319. echo
  320. stop
  321.  
  322. :WARN
  323. echo
  324. ec \201\%9\187
  325. ec \186                                                                   \186
  326. ec \186 Back at PC but your E-Mail connection might still be active.      \186
  327. ec \186  Type CONNECT (then press the Enter key) to go back to E-Mail.    \186
  328. ec \186  Type HANGUP (then Enter) to cancel your E-Mail session.          \186
  329. ec \186  Type EXIT (then Enter) to leave Kermit and go back to DOS.       \186
  330. ec \186                                                                   \186
  331. ec \200\%9\188
  332. echo
  333. stop
  334.  
  335. :CAL
  336. ;
  337. ; Columbia Calendar data entry people.
  338. ;
  339. echo 
  340. ec \201\%9\187
  341. ec \186                                                                   \186
  342. ec \186 Press any key to begin your calendar data entry session...        \186
  343. ec \186                                                                   \186
  344. ec \200\%9\188
  345. echo
  346. pause 9999
  347. output enter\13
  348. connect
  349. goto xwarn
  350.  
  351. :NOAPP
  352. echo 
  353. ec \201\%9\187
  354. ec \186                                                                   \186
  355. ec \186 You are logged in to the Info system (CUNIXF).                    \186
  356. ec \186 Press any key to start...                                         \186
  357. ec \186                                                                   \186
  358. ec \200\%9\188
  359. echo
  360.  
  361. pause 9999
  362. output \13
  363. connect
  364.  
  365. :XWARN
  366. wait 1 CD
  367. if succ goto WARN2
  368. echo 
  369. ec \201\%9\187
  370. ec \186                                                                   \186
  371. ec \186 Your connection to CUNIXF is broken.                              \186
  372. ec \186 Type EXIT (then Enter) to leave Kermit and go back to DOS.        \186
  373. ec \186                                                                   \186
  374. ec \200\%9\188
  375. echo
  376. stop
  377.  
  378. :WARN2
  379. echo
  380. ec \201\%9\187
  381. ec \186                                                                   \186
  382. ec \186 Back at PC but your CUNIXF connection might still be active.      \186
  383. ec \186                                                                   \186
  384. ec \186  Type CONNECT (then press the Enter key) to go back to CUNIXF.    \186
  385. ec \186  Type HANGUP (then Enter) to cancel your CUNIXF session.          \186
  386. ec \186  Type EXIT (then Enter) to leave Kermit and go back to DOS.       \186
  387. ec \186                                                                   \186
  388. ec \200\%9\188
  389. stop
  390.  
  391.