Ruby Forum RForum > telnet api in ruby

Posted by Supriya Agarwal (supriyaiiita)
on 11.02.2008 12:04
Hi,

Im trying to write a telnet client that will telnet to a switch in ruby.
the code im using is:

localhost = Net::Telnet::new("Host" => "10.76.151.193",
                               "Timeout" => 10,
                               "Prompt" => /[#>:]/n)  { |resp| print
"==> "+resp }
    # pass username and password as commands not .login method
    localhost.cmd("myUsername") { |c| print c }
    localhost.cmd("myPassword") { |c| print c }
    localhost.cmd("terminal length 0") { |c| print c}
@response = ''
localhost.cmd("show interfaces") { |c| print c; @response += c }
  localhost.close


what api i need to download for running this program and where should i
save it??
this program is currently not running properly!

thanks in advance!