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
on 2012-10-11 11:42
on 2012-10-11 19:53
Am 11.10.2012 11:42, schrieb Ferdous ara: > send = socket.send("recover BD-1",0) > response = socket.sead ^^^^ typo
on 2012-10-11 23:26
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.
on 2012-10-13 13:39
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 2012-10-13 14:37
On Sat, Oct 13, 2012 at 6:39 AM, Ferdous ara <firstname.lastname@example.org> 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.
on 2012-10-13 15:19
Hi no the first response is : OK Server which is, when you connect to the telnet but I need the 2nd one OK