home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / autodial < prev    next >
Text File  |  2020-01-01  |  4KB  |  90 lines

  1. #!/usr/local/bin/kermit +
  2.  
  3. ; Illustration of scripted dialup login using C-Kermit or K95.
  4. ;
  5. ; F. da Cruz, Columbia University Kermit Project, Sep 2003.
  6. ;
  7. ; This is a very simple example showing how to make a serial-port
  8. ; connection and log in to a Unix host -- nothing fancy like dialing or
  9. ; service directories, passing of parameters, etc.  See the book for
  10. ; discussion and more ambitious examples.
  11. ;
  12. ; (1) Define operating parameters (change as needed).
  13. ;
  14. def port  /dev/ttyS0                   ; Specify serial port device
  15. def modem generic-high-speed           ; Specify modem type
  16. def speed 57600                        ; Interface speed
  17. def number 1-212-555-1234              ; Number to dial
  18. def parity none                        ; (or "even") Parity to use
  19. def myuserid abc                       ; My user ID on the host
  20.  
  21. def getpass {                          ; Prompt for password
  22.     undef mypass                       ; rather than recording it
  23.     while not def mypass {             ; in this script.
  24.         askq mypass \m(tshost) Password:
  25.     }    
  26. }
  27.  
  28. ; Remove the following two commands if there is no terminal server.
  29. ; Adjust as necessary if there is.
  30.  
  31. def tsprompt >                         ; (*) Terminal server prompt if any
  32. def tshost myhost                      ; (*) Host name for terminal server
  33.  
  34. ; (2) Set dialing options:
  35.  
  36. set dial method tone                   ; (or pulse)
  37. set dial retries 20                    ; How many times to redial if busy
  38. set dial display on                    ; (or "off") Watch dialing progress
  39. set input echo on                      ; (or "off") Watch dialogs
  40.  
  41. ; (3) Make the call:
  42.  
  43. set modem type \m(modem)               ; Set modem type first
  44. set port \m(port)                      ; Then assign the port
  45. if fail exit 1 Can't open \m(port)     ; Check for failure
  46. set speed 57600                        ; Set port i/o parameters: speed
  47. set flow rts/cts                       ; i/o parameters: flow control
  48. set parity \m(parity)                  ; i/o parameters: parity
  49. dial \m(number)                        ; Dial the number
  50. if fail exit 1 Call failed.            ; Check for failure
  51.  
  52. ; (4) Dialog with terminal server, if any.  
  53. ;     This section is executed only if a terminal-server prompt is defined.
  54. ;     Customize if necessary for your terminal server's dialog.
  55. ;
  56. if def tsprompt {                      ; If terminal server prompt defined...
  57.     for \%i 1 10 1 {                   ; Try 10 times to get prompt
  58.     input 5 \m(tsprompt)           ; Wait 5 seconds for it
  59.     if success break               ; Got it - proceed
  60.     output \13                     ; No prompt - send a carriage return
  61.     }
  62.     output \m(tshost)\13               ; Output host name
  63. }
  64.  
  65. ; (5) Log in:
  66.  
  67. log session                            ; (if desired) create session.log
  68. getpass                                ; Get password from keyboard now.
  69.  
  70. for \%i 1 10 1 {                       ; Try 10 times to get login prompt
  71.     input 20 login:                    ; Wait 20 seconds for prompt
  72.     if success break                   ; Got it - proceed
  73.     output \13                         ; No prompt - send a carriage return
  74. }
  75. if > \%i 10 exit 1 No login prompt.    ; Never got one.
  76.  
  77. output \m(myuserid)\13                 ; Send user ID and carriage return.
  78.  
  79. input 10 Password:                     ; Wait 10 sec for Password: prompt.
  80. if fail exit No Password prompt.       ; Check for failure.
  81. output \m(mypass)\13                   ; Send password and carriage return.
  82. undef mypass                           ; Erase password from memory.
  83.  
  84. ; At this point you can use the "connect" command to go online for an
  85. ; interactive session, or you can continue the script.  When your session
  86. ; is complete, log out from the host.  If the host was accessed through a
  87. ; terminal server, you might have to exit or logout from the terminal
  88. ; server too.  Then tell Kermit to "hangup" to hang up the modem in case
  89. ; it is not already disconnected.
  90.