home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
rxtelnet.zip
/
nvt
/
xnvt.cmd
< prev
Wrap
OS/2 REXX Batch file
|
1997-08-17
|
2KB
|
103 lines
/**/
hostname = arg(1)
port = 0
if hostname = '' then
do
say 'enter hostname'
pull hostname
say 'enter port'
pull port
if port = '' then port = 23
end
i = 0
l = ''
echo = ''
connected = 0
EOT = '04'x
ACK = '06'x
BEL = '07'x
signal on halt
signal on error
signal on syntax
call RxFuncAdd "loadrtn","Nvt","load_routine"
call loadrtn
call RxFuncDrop "loadrtn"
socket = Telnet(hostname,port)
if socket = ''
then
say 'telnet connection failed'
else
do
connected = 1
say 'socket='socket
do while connected
call stdout
call stdin
end
end
call halt
return
stdin:
call charout,'1a'x
parse pull s
if s = '`' then
call retry
else
do
c = Tput(socket,s)
if c = 0 then
echo = ACK||s
else
connected = 0
end
return
stdout:
do forever
l = Tget(socket)
select
when l = EOT then leave
when l = '' then leave
otherwise call sayit
end
end
return
sayit:
if echo <> '' then
if l = ACK | l = echo then do; echo = ''; return; end;
say l
return
retry:
l = Tget(socket,5000)
select
when l = EOT then return
when l = '' then return
otherwise say l
end
return
syntax:
say '! syntax'
error:
say '! error'
halt:
say '! halt'
call Tquit socket
call RxFuncAdd "droprtn","Nvt","drop_routine"
call droprtn
call RxFuncDrop "droprtn"
exit