# Telnet from ruby gives 'waitfor' error

**URL:** <https://www.ruby-forum.com/t/telnet-from-ruby-gives-waitfor-error/62283>\
**Category:** Ruby\
**Created:** [June 2, 2006, 6:20am UTC](https://www.ruby-forum.com/t/telnet-from-ruby-gives-waitfor-error/62283 "2006-06-02T06:20:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![udinesh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/a87d85/32.png) [@udinesh](https://www.ruby-forum.com/u/udinesh)\
**Post date:** [June 2, 2006, 6:20am UTC](https://www.ruby-forum.com/t/telnet-from-ruby-gives-waitfor-error/62283/1 "2006-06-02T06:20:49Z")

</div>

Hi all,

I was trying to use “Telnet” from ruby as per the doc and below is the  
sample/simple program, when we execute this, i get the below output. The  
line ‘login:db2admin’ displays immediately and it pauses for sometime in  
the ‘password:’ and after few seconds i get something like ‘waitfor’…

Not sure what should be the problem and how should we correct it? Any  
ideas?

* * *

require ‘net/telnet’

tn = Net::Telnet.new({}) { |str| print str }  
tn.login(“db2admin”, “db2admin”) { |str| print str }  
tn.cmd(“date”) { |str| print str }

* * *

## OUTPUT

Trying localhost…  
Connected to localhost.  
Welcome to Microsoft Telnet Service

login: db2admin  
password:  
c:/ruby/lib/ruby/1.8/net/telnet.rb:551:in `waitfor': timed out while w aiting for more data (Timeout::Error) from c:/ruby/lib/ruby/1.8/net/telnet.rb:678:in`cmd’  
from c:/ruby/lib/ruby/1.8/net/telnet.rb:722:in `login’  
from telnet.rb:4

Thank You  
Dinesh
