Forum: Ruby telnet api in ruby

65154061b58f464fead300f86e5a5d06?d=identicon&s=25 Supriya Agarwal (supriyaiiita)
on 2008-02-11 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!
C0e4f5f10dbeefdee3b3815a17c6f53d?d=identicon&s=25 Mike Mike (mikerude82)
on 2010-07-09 21:21
Supriya Agarwal wrote:
> 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!

Hi Supriya Agarwal,

I am using Ruby-186-26 an older stable version from what i gather I am
super new to ruby but I was looking to do what your script did and it
worked for me my script was a little different but yours did the trick.
Here is the link to get the version that I am using on Windows
http://rubyinstaller.org/downloads/
Ruby 1.8.6-p26 (Final) is the name. Hope this helps.


Mike
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.