Autor: Adam Płaszczyca (trzypion_at_waw.pdi.net)
Data: Sat 01 Jul 2000 - 00:39:52 MET DST
Wkurzony koniecznością klikania na 'dial-up' w systemowym dialerze, lub
też powtarzanie komendy ppp defaultroute connect... etc. przerobiłem
nieco annex.cmd tak, żeby dało się go wykorzystać w ppp:
/*--------------------------------------------------------------------------*/
call RxFuncAdd SysSleep, RexxUtil, SysSleep
parse arg interface
/*--------------------------------------------------------------------------*/
/* Inicjalizacja i część
głowna */
/*--------------------------------------------------------------------------*/
cr='0d'x
crlf='0d0a'x
remain_buffer=''
waitfor_buffer=''
resetcmd1='ATZ'
dialcmd='atdt0w202122'
username='ppp'
password='ppp'
say 'Łączenie z telesuką ',
'(interfejs' interface')'
/* jak coś jest w buforze COM-a to wywalić */
call flush_receive
/* Dzwonimy */
call charout , 'Wybieram numer'||crlf
con=0
try=1
ORI_TIME=TIME('R')
do while con=0
call SysSleep(2)
say 'Próba 'try
call send resetcmd1 || cr
call waitfor 'OK',,'echo';
call flush_receive 'echo';
call send dialcmd || cr;
call flush_receive 'echo';
result=''
ORI_TIME=TIME('R')
do while
(pos('CONNECT',result)+pos('BUSY',result)+pos('CARRIER',result)=0)&TIME('E')<45
line=ppp_com_input(interface,,1000)
rc=charout('',line)
result=result||line
end
con=pos('CONNECT', result)
try=try+1
end
/* modem zgłosił połączenie */
call flush_receive 'echo'
call send cr
rc=waitfor('sername:', 10, 'echo');
call flush_receive 'echo';
if rc=1 then
do
say 'Brak ''Username'''
call hangup
return 1
end
call send username || cr;
rc=waitfor('ssword:', 10, 'echo');
call flush_receive 'echo'
if rc=1 then
do
say 'Brak ''Password'''
call hangup
return 1
end
call send password || cr
say crlf||'Gotowe!'
/* A teraz TPSA się cieszy, a nam kasy ubywa ;((( */
return 0
hangup:
do until rc=0
call send('+++'||cr)
rc=waitfor('OK',1)
end
do until rc=0
call send('ATH0'||cr)
rc=waitfor('OK',1)
return
/*--------------------------------------------------------------------------*/
/* send (
sendstring) */
/*..........................................................................*/
send:
parse arg sendstring
call ppp_com_output interface , sendstring
if echo!='' then say sendstring
return
/*--------------------------------------------------------------------------*/
/* waitfor ( waitstring , [timeout] , [echo]
) */
/*..........................................................................*/
waitfor:
parse arg waitstring, timeout, echo
if timeout = '' then
timeout = 5000 /* L O N G delay if not specified */
waitfor_buffer = '' ; done = -1; curpos = 1
ORI_TIME=TIME('R')
if (remain_buffer = 'REMAIN_BUFFER') then do
remain_buffer = ''
end
do while (done = -1)
if (remain_buffer \= '') then do
line = remain_buffer
remain_buffer = ''
end
else do
line = ppp_com_input(interface,,10)
end
waitfor_buffer = waitfor_buffer || line
if echo !='' then call charout('',line)
index = pos(waitstring,waitfor_buffer)
if (index > 0) then do
remain_buffer = substr(waitfor_buffer,index+length(waitstring))
waitfor_buffer =
delstr(waitfor_buffer,index+length(waitstring))
done = 0
end
call charout , substr(waitfor_buffer,curpos)
curpos = length(waitfor_buffer)+1
if ((done \= 0) & (TIME('E')>timeout)) then do
call lineout , ' WAITFOR: timed out '
done = 1
end
end
timeout=0
RC=done
return RC
/*--------------------------------------------------------------------------*/
/* flush_receive
() */
/*..........................................................................*/
flush_receive:
parse arg echo
/* If echoing the flush - take care of waitfor remaining buffer */
if (echo \= '') & (length(remain_buffer) > 0) then do
call charout , remain_buffer
remain_buffer = ''
end
/* Eat anything left in the modem or COM buffers */
/* Stop when nothing new appears for 100ms. */
do until line = ''
line = ppp_com_input(interface,,100)
if echo \= '' then
call charout , line
end
return
A teraz jak go użyć.
Wydawać by się mogło, że po wpisaniu w pole 'Login sequence' nazwy
skryptu (np. tpsadial.cmd) będzie grało. Nic bardziej mylnego. Cwany
pmslip patrzy co się dzieje na linii i kiedy zobaczy 'BUSY' to mówi
'...aborting' i spada.
Dlatego też napisałem batcha który robi to lepiej.
Lewhoo, nie marudź - wiem, lubisz PM. jak będę miał trochę czasu to
napiszę w DrRexxie.
1. Należy stworzyć plik c:\mptn\etc\resolv2.tpsa zawierający:
domain tpnet.pl
nameserver 194.204.152.34
nameserver 194.204.159.1
2. Stworzyć plik c:\tcpip\bin\tpsa.cmd zawierający:
@echo off
del c:\mptn\etc\resolv >nul:
copy c:\mptn\etc\resolv2.tpsa c:\mptn\etc\resolv2 >nul:
ifconfig lan0 down >nul:
route -fh >nul:
ppp defaultroute connect tpsadial.cmd com2 115200
call c:\mptn\bin\setup.cmd
exit
Linię z ifconfig i z call należy pominąc jeżeli macie kompa bez karty
sieciowej.
I wklepujecie po prostu tpsa i skrypt kręci numer aż do połączenia lub
ad morte defecato.
Miłej zabawy.
P.S. Lewhoo, może na Team?
-- ___________ (R) /_ _______ Adam Płaszczyca (+48 22) 631 15 03 ___/ /_ ___ ul. Ludwiki 1 m. 74, 01-226 Warszawa _______/ /_ IRC: _555, http://mike.oldfield.org.pl/ ___________/ mail: _555_at_irc.pl UIN: 4098313
To archiwum zostało wygenerowane przez hypermail 2.1.7 : Tue 18 May 2004 - 15:28:00 MET DST