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

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