home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
internet
/
demonspt
/
DEMONSPT
Wrap
Text File
|
1995-07-01
|
11KB
|
376 lines
#slipdial
#--------------------------------------------------------------------
# $Id: demon 1.6 95/06/20 23:42:00 root Exp Locker: root $
#
# Script: !SlipDial.Scripts.demon
#
# Script for calling Demon Internet Services.
#
# Credits: original R.W. Orwin 1994 (rob@wong.demon.co.uk)
# sprites James Woodman (woody@bacchus.demon.co.uk)
# new version Alan Fitch (alan@cycle.demon.co.uk)
# mercury improvements Mike James (mike@hamble.demon.co.uk)
# improved setting up Doug Macready (dougmac@newquay.zynet.co.uk)
#
# Maintained by Alan Fitch
#
call initMain
call configure
call setserial
call makemenus
call %provider
#
# main loop
#
:loop
message /close
wait /event
goto loop
exit
# end of program
#--------------------------------------------------------------------
#====================================================================
# SUBROUTINES
#====================================================================
# dial number 1 from the configuration file
:dial1
set nRetries 50
set phonenum %phonenum1
if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
goto dodial
# dial number 2 from the configuration file
:dial2
set nRetries 50
set phonenum %phonenum2
if (?ne %phonenum2 %nopredialnum) set phonenum %predial%phonenum2
goto dodial
# dial number 3 from the configuration file
:dial3
set nRetries 50
set phonenum %phonenum3
if (?ne %phonenum3 %nopredialnum) set phonenum %predial%phonenum3
goto dodial
# dial the number defined as local
:diallocal
set nRetries 50
set phonenum %localnumber
if (?ne %localnumber %nopredialnum) set phonenum %predial%localnumber
goto dodial
#-----------------------------------------------------------
# Subroutine: List
# Calls a list of phone numbers, specified below in the
# variable 'phonenum'. Returns via subroutine dodial.
# nRetries is the number of times SlipDial retries the number
# if it is busy.
# The number of retries is reduced compared to the other
# menu items (which dial only one PoP) as the intention is to
# to work through the list of numbers reasonably quickly.
#-----------------------------------------------------------
:List
set nRetries 5
set phonenum %phonenum1
if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
if (?ne %phonenum2 %nopredialnum) set phonenum "%phonenum %predial"
set phonenum "%phonenum%phonenum2"
if (?ne %phonenum3 %nopredialnum) set phonenum "%phonenum %predial"
set phonenum "%phonenum%phonenum3"
goto dodial
#-----------------------------------------------------------
# Subroutine: dodial
# Note: has multiple entry points from "goto" statements
# above. However it finally returns to the main waiting
# loop.
#-----------------------------------------------------------
:dodial
#
# kill newsbase and ttfn if they are running, and were started from SlipDial
#
# Note that if they weren't started by SlipDial, SlipDial knows nothing
# about them and will start another copy even if they are already running.
#
task /kill="Newsbase"
task /kill="TTFN"
# Claim the device driver
if (!claim 3) return 0
# initialise modem
init
# check if DSR and CTS are set
#if (?eq {?line/dsr} 0) goto no_dsr
#if (?eq {?line/cts} 0) goto no_cts
# dial the number, return to main menu if failed.
retry %nRetries 15
if (!dial /nodial=5 /nocar=3 /busy=3 %phonenum) return 0
#
# arrive here if dial succeeded
# get username/password prompts to authenticate self to server.
# after each prompt, return to main menu if failed.
#
if (!wait /del=50 ogin:) goto no_login
send %nodename
if (!wait /del=20 word:) goto no_password
send %password
if (!wait /del=50 ocol:) goto no_protocol
send %protocol
message /capture="IP" /end="HELLO" /maxlines=7 /centre
ipget 158.
if (!wait /del=30 HELLO) return 0
pause 5
task /name="TCP/IP" <TCPIP2$dir>.!Run
# watch out for carrier detect to go low
alarm /dcd "goto good_finish"
:loop2
wait /event
goto loop2
#
# Call has been finished successfully, so release the port
#
:good_finish
task /kill="TCP/IP"
message /close
message "Call finished successfully" /centre
release
# now pause for 2 seconds to allow RISC OS to sort out the display.
pause 2
#
# Start up TTFN and Newsbase.
#
if (!?task TTFN) task /name="TTFN" <TTFN$Dir>.!Run
if (!?task NewsBase) task /name="Newsbase" <NewsBase$Dir>.!Run
return 1
#
# Call failed in some way
#
:no_dsr
message/wait "Modem not ready - DSR line is not set" "(Please close this window to continue)" /centre
goto bad_finish
:no_cts
message/wait "Modem not ready - CTS line is not set" "(Please close this window to continue)" /centre
goto bad_finish
:no_login
message "Call failed - timeout waiting for login prompt" /centre
goto bad_finish
:no_password
message "Call failed - timeout waiting for password prompt" /centre
goto bad_finish
:no_protocol
message "Call failed - timeout waiting for protocol prompt" /centre
goto bad_finish
:bad_finish
pause 1
release
reinit
return 0
#-----------------------------------------------------------
# Subroutine: Bt
# Set the provider to BT
#-----------------------------------------------------------
:bt
set provider bt
icon /id="Mercury" /action="call bt" hgoff
set predial ""
message "service provider set to BT" /centre
pause 1
return 1
#-----------------------------------------------------------
# Subroutine: Mercury
# Set the provider to Mercury
#-----------------------------------------------------------
:mercury
set provider Mercury
icon /id="Mercury" /action="call mercury" hgon
set predial %mercury_pin
message "service provider set to Mercury" /centre
pause 1
return 1
#-----------------------------------------------------------
# Subroutine: makemenus
# Defines the menus for dialling etc. Note the length of
# all the names must be less than 255 characters total, as
# must the length of all the commands.
#-----------------------------------------------------------
:makemenus
menu "%name1:call dial1" "%name2:call dial2" "%name3: call dial3" "List:call List"
menu /icon="Mercury" "Mercury:call mercury" "BT:call bt" "Save Default:call saveconfig"
menu /icon="Local" "Local call:call diallocal"
return 1
#-----------------------------------------------------------
# Subroutine: setserial
# Set Serial Port/Driver Parameters
#-----------------------------------------------------------
:setserial
driver %driver
port %wport %prtnum
speed %speed
set protocol slip
return 1
#-----------------------------------------------------------
# Subroutine: setup1
# Called to setup defaults if no configuration file present.
#-----------------------------------------------------------
:setup1
input/prompt="Enter Serial Block Driver Name : " wport
input/prompt="Enter Serial Port Number (if relevant) : " prtnum
input/prompt="Enter Your Modem->Computer Speed (bps) : " speed
input/prompt="Enter Your Demon Nodename : " nodename
input/prompt="Enter Your Password : " password
input/prompt="Enter Your Modem Driver Name (e.g. USR): " driver
input/prompt="Enter Telephone Provider (BT/Mercury) : " provider
input/prompt="Enter Your Mercury PIN : " mercury_pin
input/prompt="Enter NAME of main number e.g. London : " name1
input/prompt="Enter NUMBER of main number e.g. 01813384848 : " phonenum1
input/prompt="Enter NAME of 2nd number : " name2
input/prompt="Enter NUMBER 2nd number : " phonenum2
input/prompt="Enter NAME of 3rd number : " name3
input/prompt="Enter NUMBER of 3rd number : " phonenum3
input/prompt="Enter nearest NUMBER, e.g. 01813384848 : " localnumber
input/prompt="Enter your non-mercury number, e.g. 01813384848 : " nopredialnum
:saveconfig
set filename {?file/expand slipdial:demconfg}
open/id=conf/write %filename
write/id=conf %wport
write/id=conf %prtnum
write/id=conf %speed
write/id=conf %nodename
write/id=conf %password
write/id=conf %driver
write/id=conf %provider
write/id=conf %mercury_pin
write/id=conf %name1
write/id=conf %phonenum1
write/id=conf %name2
write/id=conf %phonen