我对 ruby 非常陌生,只是想用它来做一些基本的脚本。即telnet进入一台机器并使用dos ftp客户端拉一些文件。
我遇到的问题是,当我尝试手动 telnet 进入机器(从命令提示符)时,我收到以下消息:
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'