# Telnet Hangs During Login

**URL:** <https://www.ruby-forum.com/t/telnet-hangs-during-login/169799>\
**Category:** Ruby-Forum\
**Created:** [June 8, 2009, 10:48pm UTC](https://www.ruby-forum.com/t/telnet-hangs-during-login/169799 "2009-06-08T22:48:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmichelson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/db5fbb/32.png) [@gmichelson](https://www.ruby-forum.com/u/gmichelson)\
**Post date:** [June 8, 2009, 10:48pm UTC](https://www.ruby-forum.com/t/telnet-hangs-during-login/169799/1 "2009-06-08T22:48:46Z")

</div>

This is cross-posted on stackoverflow if you want points/nice syntax  
highlighting:

> <https://stackoverflow.com/questions/966820/ruby-scripting-telnet-hangs-during-login>

I am trying to do some basic scripting using ruby to log in to a windows  
machine via telnet and pull some files over using the dos command line  
ftp. When I do this manually everything goes swimmingly but when I try  
it via ruby I’m getting an error in the login call.

Here is my test program in its entirety:

```
require 'net/telnet'
tn = Net::Telnet::new("Host"=>"xxx.xxx.xxx.xxx", "Timeout"=>25,

```

“Output\_log”=\>“output\_log.log”, “Dump\_log”=\> “dump\_log.log”,  
“Prompt”=\>“C:.\*\>”)  
tn.login(“administrator”, “xxxxxxx”) {}  
tn.cmd(‘dir’)  
exit

The contents of output\_log don’t betray anything as being wrong:

```
Trying 208.10.202.187...
Connected to 208.10.202.187.
Welcome to Microsoft Telnet Service
login: administrator
password:
*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\Administrator>

```

Same for the dump\_log which has very similar but awkwardly formatted  
contents. When I run the program it sits around for a while and then  
outputs the following error:

```
PS C:\code\tools\deployment> ruby test.rb
C:/Ruby/lib/ruby/1.8/net/telnet.rb:551:in `waitfor': timed out while

```

waiting for more data (Timeout::Error)  
from C:/Ruby/lib/ruby/1.8/net/telnet.rb:685:in `cmd' from C:/Ruby/lib/ruby/1.8/net/telnet.rb:730:in `login’  
from test.rb:3

Which leads me to suspect that the telnet class is not recognizing the  
command prompt. I’ve tried several different regex strings for the  
Prompt parameter, including the default and nothing seems to help.
