2
我正在尝试使用ruby通过telnet登录到Windows机器并使用dos命令行ftp将一些文件拖过来进行一些基本脚本。当我手动执行这些操作时,一切都会顺利进行,但是当我通过ruby尝试时,我在登录调用中遇到了错误。Ruby脚本 - 登录时挂起的Telnet
这里是全部我的测试程序:
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
output_log的内容不出卖任何东西为错误:
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>
同样为它具有非常相似,但笨拙的dump_log格式化的内容。当我运行该程序就坐在了一段时间,然后输出以下错误:
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
这使我怀疑的telnet类是不能识别的命令提示符。我已经尝试了Prompt参数的几个不同的正则表达式字符串,包括默认和没有任何帮助。
哦真棒,感谢拉里现在的伟大工程 – 2009-06-08 21:36:59