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!
on 2008-02-11 12:04
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
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.