aris
October 11, 2012, 11:42am
1
Hi
i am trying to telnet by ruby… i went through google. but i am bit
confused.
so i need bit help
require ‘socket’
host = ‘localhost’
port = 5555
socket = TCPSocket.open(host,port)
send = socket.send(“recover BD-1”,0)
response = socket.sead
print response
basically, if i do from command line
telnet localhost 5555
OK Server
recover BD-1 : then i will type this
and then telnet will output
OK
so i need to get that OK
but that socket is not doing anything
Can some one help me out please
Am 11.10.2012 11:42, schrieb Ferdous ara:
send = socket.send(“recover BD-1”,0)
response = socket.sead
^^^^
typo
ferdous
October 11, 2012, 11:26pm
3
Ferdous ara wrote in post #1079397:
Hi
i am trying to telnet by ruby… i went through google.
Then you should have found Net::Telnet which is part of the ruby
standard library.
But then maybe you don’t actually want telnet; what you want is to
communicate over a TCP socket.
In that case, beware that the protocol will probably require you to end
the command with \r\n, or at least \n, which you are not sending at the
moment.
HI
i found the solution i had to put
sock.puts “recover BD-1\r\n”
response = sock.read
i had to put \r\n
i guess its specifiq to environment .
but only problem is ,
its giving me 2 out put
OK Server
Ok
but how will just take the last output which is OK?
do i have to take the value as array ??
thanks
On Sat, Oct 13, 2012 at 6:39 AM, Ferdous ara [email protected]
wrote:
but only problem is ,
its giving me 2 out put
OK Server
Ok
but how will just take the last output which is OK?
do i have to take the value as array ??
It sounds like it’s receiving and responding to \r and then \n. Just
take the first output.
Hi
no the first response is :
OK Server
which is, when you connect to the telnet
but I need the 2nd one
OK