; ~jhs/bin/kermit.isp.common --> personal/kermit.isp.common
;	by Julian H. Stacey
; DO NOT EDIT kermit.isp.gate & kermit.isp.desk
; as they are produced via Makefile & le

; Warning: There's a timing problem to be aware of:
; kermit takes time to process all these lines with semi colons (;)
; so if you remove a load of comments the script will run faster,
; and you may need to add a sleep instead !

run ls -l	/var/log/slip/ibm/debugging.log
log debugging	/var/log/slip/ibm/debugging.log

run ls -l	/var/log/slip/ibm/session.log
log session	/var/log/slip/ibm/session.log

echo \13
echo kermit.isp.common --> ../../../private/bin/kermit.isp.private \13
take ../../../private/bin/kermit.isp.private
; ../../../private/bin/kermit.isp.private contains assigns such as:
;	assign \%n 123456
;	assign \%u username
;	assign \%v pass1
;	assign \%w pass2
echo ../../../private/bin/kermit.isp.private --> kermit.isp.common\13
; echo Dial Number \%n x \\%n xx %n\13
; echo Login and 2 passwords: \%u \%v \%w\13

set line /dev/cuaa1
assign \%s 57600
set speed \%s
set flow rts/cts

output ate1\13
input 2 OK
if failure goto failed

; For log file, so we know which modem was last used etc.
output ati3\13
; Escom
;	AT-1496SA-EUR 06/01/1993 FOR GERMANY

input 2 OK
if failure goto failed

output atz\13
input 2 OK
if failure goto failed
sleep 2

; Initialise
; for escom white, works for slip downloads, but not uploads
clear

;	White Escom does not allow &f2
output at&f\13
input 2 OK
if failure goto failed

output ate0\13
input 2 OK
if failure goto failed

output at&k3\13
input 2 OK
if failure goto failed

; causes kermit to stop talking to the modem
; output at\\n3\13
; input 2 OK
; if failure goto failed

output atw0\13
input 2 OK
if failure goto failed

output at\\q3\13
input 2 OK
if failure goto failed

output atm1\13
input 2 OK
if failure goto failed

; white escom does not allow atn	(redial is regulated for german modems)

output atl1\13
input 2 OK
if failure goto failed

output at&c0\13
input 2 OK
if failure goto failed

output at&d0\13
input 2 OK
if failure goto failed
; white escom does not allow at&q	(in supra it asserts async reliable)

output at&t5\13
input 2 OK
if failure goto failed

; %G rate renogiation is done by supra but not discovery & white escom

output ats2=43\13
input 2 OK
if failure goto failed

output ats10=254\13
input 2 OK
if failure goto failed

output ats12=50\13
input 2 OK
if failure goto failed

output ats37=0\13
input 2 OK
if failure goto failed

output at&w0\13
input 2 OK
if failure goto failed

; output at&w1\13
; input 2 OK
; if failure goto failed

; escom white fails to hold line after saying INTERNET \13at&f2e0b0l2m1n1&c1&d2&q5&q9&t5%g1s2=43s10=254s12=50s37=0&w1\13

output atdt\%n\13
; Example output atdt123456\13
; sja prefixes 089 even though he's in Munich call area, to get better line.

minput 60 {CONNECT 14400/V42BIS} {CONNECT 14400} {CONNECT \%s}
if failure goto failed

;	&	(single char, no return must be issued within about 3 seconds)
output &
;		Enter dial script version ==>
input 20 ersion ==>
if failure goto failed
echo 1.1\13
output 1.1\13

;		Enter Service ==>
input 5 ervice ==>
if failure goto failed
echo INTERNET\13
output INTERNET\13

;		Enter account userID password [/new_password]==>
;		Enter Account UserId Password ==>
input 5 ==>
if failure goto failed

echo \10 Emiting Login and 2 passwords
; It accepts both upper & lower case.

; output u1234 p1234 p5678\13
output \%u \%v \%w\13

;		139.92.18.170 is your IP Address
input 60 ddress
if failure goto failed2

; \Feval(expr)        evaluate arithmetic expression
; \Findex(a1,a2,a3)   position of string a2 in a1, starting at pos a3
; the above description of findex comes from man kermit from cku190.tar.gz )
;	HOWEVER the above doesnt work, whereas sja's order does !
;	assign \%o \Findex(139,\v(input),1)
; \Fsubstr(a1,a2,a3)  substring of a1, starts at a2, length a3

; clear	; try this next
assign \%o \Findex(139,\v(input),0)
echo \10
; echo JHS 139 is at \%o in buffer
assign \%x \Findex(\32,\v(input),\%o)
; echo JHS space is at \%x
assign \%m \Feval(\%x-\%o)
; echo JHS address string length is \%m
assign \%a \Fsubstr(\v(input),\%o,\%m)
; echo JHS Your Local Address is \%a
assign \%l \%a

clear
;	139.92.18.170	(return your dynamically assigned local address)
output \%a\13

input 60 ddress
if failure goto failed2

;		152.158.16.43 is your Destination Address
assign \%o \Findex(152,\v(input),0)
echo \10
; echo JHS 152 is at \%o in buffer
assign \%x \Findex(\32,\v(input),\%o)
; echo JHS space is at \%x
assign \%m \Feval(\%x-\%o)
; echo JHS address string length is \%m
assign \%a \Fsubstr(\v(input),\%o,\%m)
; echo JHS Destination Remote Address is \%a
assign \%r \%a

;	slattach -h -s 57600 /dev/cuaa1
;	ifconfig sl0  139.92.18.170  152.158.16.43  up
;	route add default 152.158.16.43

; maybe next bits will fail on exclusive open

echo Now running	slattach -h -s \%s /dev/cuaa1
; -h	Turn on cts/rts, else by default none.
run	slattach -h -s \%s /dev/cuaa1

echo Now running	ifconfig sl0 \%l \%r up
run	ifconfig sl0 \%l \%r up

; echo Now running	route add default \%r
run	route add default \%r
echo Calling: ~jhs/bin/.sh/net
run ~jhs/bin/.sh/net

goto end

;		Begin TCP/IP communication now.
input 10 TCP
if failure goto failed

:FAILED
echo Connection failed
goto end

:FAILED2
reinput 1 ailable
if failure goto failed
echo \13No IP addresses are available\13
echo Why can't it tell you before it's cost a unit ?
goto end

:END
quit
