home *** CD-ROM | disk | FTP | other *** search
/ Univers Interactif 3 / INTERACTIF.BIN / pc / planeten / internet / macslipc.sit / macslip-cisco-script next >
Text File  |  1994-01-22  |  5KB  |  224 lines

  1. # This script is designed to dial a Hayes compatible modem and converse
  2. # with a Cisco terminal server to establish a SLIP connection. It
  3. # shouldn't be too hard to adapt to other modems or terminal servers
  4. # just by changing a few "ifmatch" target strings.
  5. #
  6. # You should preset the following parameters by using the "Scan Script"
  7. # button in the "Variables" dialog.
  8. #
  9. # $user -- username to log into the terminal server
  10. # $phone -- the phone number to dial
  11. #
  12. # Using default settings, the modem will be initialized before this script
  13. # starts running.
  14.  
  15. # Let the user know we're starting up. Set up a global
  16. # abort action.
  17.  
  18. on restart goto restart
  19. on abort goto abort
  20. label startup
  21. message "Script starting..."
  22.  
  23. # If a password variable is not defined in the connection
  24. # set, ask for a password to log into the SLIP server.
  25.  
  26. ifdef password goto noaskp
  27. message "Will login to SLIP server as $user.\n\bPassword:"
  28. askp password
  29. label noaskp
  30.  
  31. # Dial the phone and wait for the terminal server to send its login
  32. # banner. Some areas support using *70 as a dialing prefix to suppress
  33. # call-waiting tones which will probably cause your modem
  34. # to lose the connection. Some terminal servers may require you to
  35. # autobaud before they will respond. Allow enough time for the modem
  36. # handshake to complete.
  37.  
  38. label redial
  39. message "Dialing $phone..."
  40. flush
  41. on abort goto hangupabort
  42. send "ATDT $phone\r"
  43.  
  44. {
  45.     ifmatch "login:" break
  46.     ifmatch "NO DIALTONE" goto nodialtone
  47.     ifmatch "BUSY" goto phonebusy
  48.     ifmatch "NO CARRIER" goto nocarrier
  49.     iftime 1:15 goto dialtimeout
  50. }
  51.  
  52. # Log into the terminal server. Try three times to send the username. Use
  53. # counter #1 to count the number of login attempts.
  54.  
  55. setcount 1 0
  56. label login
  57. ifcountgt 1 3 goto cantlogin
  58. message "Logging in as $user..."
  59. setcount 0 0
  60. label user
  61. flush
  62. ifcountgt 0 3 goto baduser
  63. send "$user\r"
  64. {
  65.     ifmatch "Password:" break
  66.     ifmatch "login:" goto user
  67.     iftime 10 goto baduser
  68. }
  69.  
  70. # Send your password and wait for the ">" prompt. If we see the
  71. # "Username:" prompt again, then we didn't get logged in so try again.
  72.  
  73. message "Sending password..."
  74. flush
  75. send "$password\r"
  76. goto setslip
  77.  
  78. label accessdenied
  79. {
  80.     ifmatch "login:" goto login
  81.     ifmatch "NO CARRIER" goto cantlogin
  82.     iftime 10 goto cantlogin
  83. }
  84. goto cantlogin    # Shouldn't get here, but just in case
  85.  
  86.  
  87. # Setup the slip server. "Terminal download" is Cisco specific. If you're
  88. # not using a Cisco, replace this section with any commands specific to
  89. # your slip server.
  90.  
  91. label setslip
  92.  
  93. {
  94.     ifmatch "beginning...." break
  95.     iftime 40 goto cantstartslip
  96. }
  97. ipfind IPGWADDRESS IPADDRESS
  98.  
  99. # All done.  Send message to alert the user, flush the junk out of the
  100. # receive buffer, and return success.
  101.  
  102. message "Script complete"
  103. flush
  104. return 1
  105.  
  106. # Error handlers.
  107.  
  108. label abort
  109. beep
  110. message "\bCommand-. seen or Cancel button clicked."
  111. goto aborted
  112.  
  113. label hangupabort
  114. beep
  115. message "\bCommand-. seen or Cancel button clicked."
  116. goto hangup
  117.  
  118. label cantfindmodem
  119. beep
  120. message "\bThe modem didn't respond to attention"
  121. message "\bbsignal.  Check modem and cabling."
  122. goto aborted
  123.  
  124. label cantinitmodem
  125. beep
  126. message "\bThe modem didn't respond to initialization"
  127. message "\bstring.  Check the modem."
  128. goto aborted
  129.  
  130. label nodialtone
  131. beep
  132. message "\bThe modem could not detect a dialtone."
  133. message "\bCheck the phone line."
  134. goto aborted
  135.  
  136. label phonebusy
  137. beep
  138. message "\bThe number $phone is busy."
  139. delay 1
  140. goto redial
  141.  
  142. label nocarrier
  143. beep
  144. message "\bThe modem could not establish a connection."
  145. message "\bMake sure there is a modem on the other end."
  146. delay 1
  147. goto redial
  148.  
  149. label dialtimeout
  150. message "\bThe modem or SLIP server isn't responding."
  151. message "\bTry dialing manually to make sure the modem"
  152. message "\band SLIP server are OK."
  153. goto aborted
  154.  
  155. label baduser
  156. beep
  157. message "\bThe SLIP server won't accept a username."
  158. message "\bTry dialing manually to make sure the SLIP"
  159. message "\bserver is OK."
  160. goto hangup
  161.  
  162. label cantlogin
  163. beep
  164. message "\bLogin to SLIP server failed, check username"
  165. message "\band password."
  166. goto hangup
  167.  
  168. label cantsetterm
  169. beep
  170. message "\bCan't set terminal line for SLIP operation."
  171. goto hangup
  172.  
  173. label cantstartslip
  174. beep
  175. message "\bCan't put server into SLIP mode."
  176. goto hangup
  177.  
  178. # General back-end for bailing out.
  179.  
  180. label hangup
  181. do disconnect
  182. # fallthrough into aborted
  183.  
  184. label aborted
  185. message "\bScript aborted!"
  186. # This activates the OK button.
  187. ask junk
  188. flush
  189. return 0
  190.  
  191. # Restart procedure.
  192. # This label is entered when you click the restart button in the
  193. # connection dialog. We try to force the modem to hang up, then we go back
  194. # to the start of the script.
  195.  
  196. label restart
  197. do disconnect
  198. delay 2
  199. message "\bScript restarted."
  200. goto startup
  201.  
  202. # Disconnect procedure. The "disconect" procedure is called by MacSLIP
  203. # when the "Disconnect" button is clicked. This procedure escapes the
  204. # modem into command mode and hangs up the phone. The +++ escape sequence
  205. # is surrounded by delays that some modems require.
  206.  
  207. label disconnect
  208. send "\d\d+++\d\dATH\r"
  209. flush
  210. return 1
  211.  
  212. # Alternate disconnect procedure for modems that drop into command mode
  213. # when DTR is dropped. You may want to try this alternate disconnect
  214. # procedure if the one above doesn't work for your modem. Just swap the
  215. # labels to use this one instead of the one above.
  216.  
  217. label disconnect2
  218. dtr off
  219. delay 3
  220. send "ATH\r"
  221. dtr on
  222. flush
  223. return 1
  224.