# Telnet api in ruby

**URL:** <https://www.ruby-forum.com/t/telnet-api-in-ruby/128765>\
**Category:** Ruby\
**Created:** [February 11, 2008, 12:04pm UTC](https://www.ruby-forum.com/t/telnet-api-in-ruby/128765 "2008-02-11T12:04:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![supriyaiiita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@supriyaiiita](https://www.ruby-forum.com/u/supriyaiiita)\
**Post date:** [February 11, 2008, 12:04pm UTC](https://www.ruby-forum.com/t/telnet-api-in-ruby/128765/1 "2008-02-11T12:04:15Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![supriyaiiita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@supriyaiiita](https://www.ruby-forum.com/u/supriyaiiita)\
**Post date:** [July 9, 2010, 9:21pm UTC](https://www.ruby-forum.com/t/telnet-api-in-ruby/128765/2 "2010-07-09T21:21:33Z")

</div>

Supriya A. 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 A.,

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

> **[Downloads](https://rubyinstaller.org/downloads/)**
>
> The easy way to install Ruby on Windows This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important...

Ruby 1.8.6-p26 (Final) is the name. Hope this helps.

Mike
