home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
ckscripts.tar.gz
/
ckscripts.tar
/
autodial
< prev
next >
Wrap
Text File
|
2003-09-17
|
4KB
|
90 lines
#!/usr/local/bin/kermit +
; Illustration of scripted dialup login using C-Kermit or K95.
;
; F. da Cruz, Columbia University Kermit Project, Sep 2003.
;
; This is a very simple example showing how to make a serial-port
; connection and log in to a Unix host -- nothing fancy like dialing or
; service directories, passing of parameters, etc. See the book for
; discussion and more ambitious examples.
;
; (1) Define operating parameters (change as needed).
;
def port /dev/ttyS0 ; Specify serial port device
def modem generic-high-speed ; Specify modem type
def speed 57600 ; Interface speed
def number 1-212-555-1234 ; Number to dial
def parity none ; (or "even") Parity to use
def myuserid abc ; My user ID on the host
def getpass { ; Prompt for password
undef mypass ; rather than recording it
while not def mypass { ; in this script.
askq mypass \m(tshost) Password:
}
}
; Remove the following two commands if there is no terminal server.
; Adjust as necessary if there is.
def tsprompt > ; (*) Terminal server prompt if any
def tshost myhost ; (*) Host name for terminal server
; (2) Set dialing options:
set dial method tone ; (or pulse)
set dial retries 20 ; How many times to redial if busy
set dial display on ; (or "off") Watch dialing progress
set input echo on ; (or "off") Watch dialogs
; (3) Make the call:
set modem type \m(modem) ; Set modem type first
set port \m(port) ; Then assign the port
if fail exit 1 Can't open \m(port) ; Check for failure
set speed 57600 ; Set port i/o parameters: speed
set flow rts/cts ; i/o parameters: flow control
set parity \m(parity) ; i/o parameters: parity
dial \m(number) ; Dial the number
if fail exit 1 Call failed. ; Check for failure
; (4) Dialog with terminal server, if any.
; This section is executed only if a terminal-server prompt is defined.
; Customize if necessary for your terminal server's dialog.
;
if def tsprompt { ; If terminal server prompt defined...
for \%i 1 10 1 { ; Try 10 times to get prompt
input 5 \m(tsprompt) ; Wait 5 seconds for it
if success break ; Got it - proceed
output \13 ; No prompt - send a carriage return
}
output \m(tshost)\13 ; Output host name
}
; (5) Log in:
log session ; (if desired) create session.log
getpass ; Get password from keyboard now.
for \%i 1 10 1 { ; Try 10 times to get login prompt
input 20 login: ; Wait 20 seconds for prompt
if success break ; Got it - proceed
output \13 ; No prompt - send a carriage return
}
if > \%i 10 exit 1 No login prompt. ; Never got one.
output \m(myuserid)\13 ; Send user ID and carriage return.
input 10 Password: ; Wait 10 sec for Password: prompt.
if fail exit No Password prompt. ; Check for failure.
output \m(mypass)\13 ; Send password and carriage return.
undef mypass ; Erase password from memory.
; At this point you can use the "connect" command to go online for an
; interactive session, or you can continue the script. When your session
; is complete, log out from the host. If the host was accessed through a
; terminal server, you might have to exit or logout from the terminal
; server too. Then tell Kermit to "hangup" to hang up the modem in case
; it is not already disconnected.