Hi all
I'm having some trouble with Telnet on Ruby
I'm communicating with a server, and the response code is always
something like this:
>
><next>
FCX: ?><next>
FCY: ?>
FCY: ?>drive
FCY: drive>dylan
FCY: dylan>he
FCY: dylan><next>
><next>
FCX: ?>drive
FCX: drive>dyl
You switch interfaces between X/Y and Console by using Ctrl-T so that's
fine
My code so far is:
tn = Net::Telnet.new("Host" => "10.54.30.40","Timeout" =>
10,"Telnetmode"=>false,"Prompt"=>"/[.*>]/","Dump_log"=>"C:/temp/dump.log")
tn.puts(?\024)
tn.cmd('dylan stat')
tn.cmd("String"=>'con sh',"match"=>' >')
the responses are valid, and both the dump log and wireshark agree that
the response back from the server is
[block of data]
>
dump log extract:
# 0x00000: 43 6f 6e 6e 65 63 74 65 64 20 74 6f 20 31 30 2e Connected
to 10.
# 0x00010: 35 34 2e 33 30 2e 34 30 2e 0a
54.30.40..
0x00000: 63 6f 6e 20 73 68 0d 0a con sh..
< 0x00000: ff fb 01 ...
< 0x00000: 63 6f 6e 20 73 68 0d 0a con sh..
< 0x00000: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
ยทยทยท
----------------
< 0x00010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
----------------
< 0x00020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
----------------
< 0x00030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
----------------
... large block of data....
< 0x00090: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
----------------
< 0x000a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d
----------------
< 0x000b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 0d 0a 54 77
----------....Tw
< 0x000c0: 65 61 6b 73 3a 20 30 20 3a 20 24 30 30 20 24 30 eaks: 0 :
$00 $0
< 0x000d0: 30 20 24 30 30 20 24 30 30 20 24 30 30 20 24 30 0 $00 $00
$00 $0
< 0x000e0: 30 20 24 30 30 20 24 30 30 20 24 30 30 20 24 30 0 $00 $00
$00 $0
< 0x000f0: 30 20 24 30 30 20 24 30 30 20 24 30 30 20 24 30 0 $00 $00
$00 $0
< 0x00100: 30 20 24 30 30 20 24 30 30 20 0d 0a 0d 0a 46 6c 0 $00 $00
....Fl
< 0x00110: 61 67 73 3a 0d 0a 50 72 69 6e 74 42 61 64 0d 0a
ags:..PrintBad..
< 0x00120: 52 65 70 53 69 67 45 72 72 73 0d 0a 50 72 69 6e
RepSigErrs..Prin
< 0x00130: 74 42 6c 61 63 6b 0d 0a 50 72 69 6e 74 41 6c 6c
tBlack..PrintAll
< 0x00140: 42 6c 61 63 6b 0d 0a 0d 0a Black....
< 0x00000: 20 3e >
How do I set up my prompt so that it gives me the correct responses and
doesn't constantly timeout?
The response to my last message in the console was:
irb(main):046:0> tn.cmd("String"=>'con sh',"match"=>' >')
Timeout::Error: timed out while waiting for more data
from C:/Ruby/lib/ruby/1.9.1/net/telnet.rb:558:in `waitfor'
from C:/Ruby/lib/ruby/1.9.1/net/telnet.rb:697:in `cmd'
from (irb):46
from C:/Ruby/bin/irb:12:in `<main>'
Many thanks
Scott
--
Posted via http://www.ruby-forum.com/\.