我对 ruby 非常陌生,只是想用它来做一些基本的脚本。即 telnet 到一台机器并使用 dos ftp 客户端将一些文件拉过来。
我遇到的问题是当我尝试手动远程登录到机器时(从命令提示符)我收到以下消息:
Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' You are about to send your password information to a remote computer in Internet zone. This might not be safe. Do you want to send anyway(y/n):
当我使用 ruby 的 telnet 类 (net/telnet) login() 时,它卡在密码提示上。这使我认为它没有考虑消息,将用户名发送到消息,将密码发送到用户名提示。我该如何处理这种情况?
编辑:登录过程似乎在密码提示期间挂起。我只是怀疑这是由上述消息引起的,任何其他想法都会受到赞赏。我试图回应所有内容,但得到以下信息:
irb(main):030:0> tn = Net::Telnet::new("Host"=>"xxx.xxx.xxx.xxx", "Timeout"=>10) => #<TCPSocket:0x2d8aafc>
irb(main):031:0> tn.login("administrator", "password") {|c| print c}
Welcome to Microsoft Telnet Service
login: administrator
password: Timeout::Error: timed out while waiting for more data
from C:/Ruby/lib/ruby/1.8/net/telnet.rb:551:in `waitfor'
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'
最佳答案
我想通了。如果其他人遇到问题但我的超时设置太低,则不会删除它。将其设置为 25 解决了这个问题。
关于在输入密码提示期间,Ruby telnet 挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/965004/