home *** CD-ROM | disk | FTP | other *** search
- #slipdial
- #----------------------------------------------------------------
- # Script to perform initial dial-up to Demon.
- # This is needed to set a password and get the IP address.
- #----------------------------------------------------------------
-
- # Set trace level
- debug 3
-
- # Configure
- set wport "Internal"
- set prtnum 0
- set speed 57600
- set nodename "nyphot"
- set password "abcdefggffff"
-
- # Initialise the modem driver
- driver USR
- port %wport %prtnum
- speed %speed
-
- # Ring the first-choice PoP
- set phonenum 01212754848
-
- # Claim the device driver
- if (!claim 3) goto noclaim
-
- # Initialise the modem
- if (! init) goto noinit
-
- # Dial Demon; exit if failed
- if (!dial /retry=1 /delay=10 %phonenum) goto noanswer
-
- # Hurrah, we got in! No we expect:
- # <machine>.demon.co.uk (tty<something>):
- # demon login:
- # To which we reply with our nodename.
-
- if (!wait /delay=30 "login:") goto nologin
- send %nodename
-
- # Now Demon should say:
- # There is no password on your account....
- # Password:
- # If the password has already been set, it just prompts for the password.
- if (!wait /delay=10 "Password:") goto nopass
- send %password
-
- # If the account is a new one, Demon now prompt with:
- # ...wasn't mistyped:
- # If it's already been set up, we get:
- # Protocol:
- # If the account is not set up, or is set up with a different password,
- # we get:
- # Login incorrect
- set response {wait/delay=20 "typed:" "Protocol:" "incorrect"}
- if (?eq %response 0) goto noip
- if (?eq %response 3) goto badnode
-
- # If logging in for the first time, need to confirm the password
- # Otherwise, tell it what protocol
- if (?eq %response 1) send %password
- if (?eq %response 2) send "slip"
-
- # We should now get
- # <nodename>: IP Address: 158.152.<whatever> ...
- # So we just need to capture the IP address
- message/capture/max=20
- if (!ipget/delay=300 "158.152.") goto noip
-
- # Hang up the phone line
- release
-
- # Export the IP address for !NetConfig to pick up
- oscli "Set Demon$IpAddress %ipaddress"
-
- # Restart !DemConfig to finish the configuration
- message/centre "IP address successfully retrieved."
- message/add/centre %ipaddress
- message/add/centre/wait "Close this window to return to !NetConfig."
- quit
-
- # ---- Error handling ----
- :noclaim
- set err1 "Unable to claim the device driver."
- set err2 "Is something else using the serial port?"
- goto fail
-
- :noinit
- set err1 "Modem initialisation failed."
- set err2 "Is it connected and switched on?"
- goto fail
-
- :noanswer
- release
- set err1 "No dialling tone, no answer, engaged or no carrier."
- set err2 "Check modem settings and/or try again later."
- goto fail
-
- :nologin
- release
- set err1 "No 'login:' prompt after 20 seconds"
- set err2 "Demon being very slow? Try again later."
- goto fail
-
- :nopass
- release
- set err1 "No 'Password:' prompt after 10 seconds"
- set err2 "Demon being very slow? Try again later."
- goto fail
-
- :noip
- release
- set err1 "No IP address forthcoming from Demon."
- # Don't know what might have happened here...
- set err2 "Click ADJUST on the SLIPdial icon to see the log."
- goto fail
-
- :badnode
- release
- set err1 "Demon say your nodename / password are incorrect."
- set err2 "Is account set up yet? Or is another password already set?"
- goto fail
-
- # --- Common exit point on error
- :fail
- message/centre "*** Initial login to Demon failed ***"
- message/add/centre "%err1"
- message/add/centre "%err2"
- message/add/centre/wait "Close this window to return to !NetConfig."
- quit
-