I am trying to use Net::Telnet to telnet to a website  to check network
connectivity...

On linux prompt i get the following output:

$ telnet to abc.xyz.com 443
Trying xxx.xxx.xxx.xxx...
Connected to abc.xyz.com.
Escape character is '^]'.
hello world
Connection closed by foreign host.


When I type in "hello world" string it responds with "Connection closed
by foreign host." which is what is expected and I need to check with
telnet. In the script, I need to put a error checking code which detect
if the port is blocked and it should timeout. How can I use Net::Telnet
to put the string "hello world" in order to get appropriate response or
timeout on hangs.
Here is my code:

******************************
#!/usr/bin/env ruby

require 'net/telnet'

host = Net::Telnet::new(
        "Host" => " abc.xyz.com",
        "Port" => 443,
        "Telnetmode" => false,
        "Output_log" => "telnet.log",
        "Dump_log"   => "dump_log.log"
        )

lines = "Hello World !!!!!!"


    host.puts(lines)

    host.waitfor(/./)do |data|
    puts data
    end

******************************

All the response I get from this script is "nil"


Can someone help me with this !

-- 
Posted via http://www.ruby-forum.com/.