Ruby Telnet Lib - 奇怪的响应
我正在尝试通过 telnet 在远程 CPU 上执行 cmd。虽然发送的一些命令(通过 Ruby 的用于 telnet 的 stdlib)成功,但其他命令却给了我一个奇怪的响应:
*================================================ =================
欢迎使用 Microsoft Telnet 服务器。
*==================================================== ==============
C:\Documents and Settings\UserJW>ls
桌面
收藏夹
我的文档
开始菜单
Sti_Trace.logC:\Documents and Settings\UserJW>cd\
更多的?
为什么 telnet 给我这个“更多”?回应,好像在期待什么?
在代码中,我只是连接到远程 CPU、登录并发送命令:
@connection = Net::Telnet.new(...)
@connection.login( user, pwd )
@connection.cmd(...)
任何帮助将不胜感激。
谢谢, J
**编辑:
<代码>@connection = Net::Telnet.new(
“主机”=>机器,
“提示”=> /[A-Za-z]:\\.*>\z/n,
“超时”=> 3、
“输出日志”=>输出)
@connection.login( 用户, 密码 )
@connection.cmd( 'ls' )
@connection.cmd( 'ls' ) 输出
...
C:\Documents and Settings\UserJW>
ls
桌面
收藏夹
我的文档
开始菜单
Sti_Trace.log
C:\Documents and Settings\UserJW>
ls
更多的?
显然,我什至无法发送多个命令。我的提示正则表达式错误吗?我试图允许..
C:[任何事情...]>
I am trying to execute cmds on a remote CPU through telnet. While some commands sent (through Ruby's stdlib for telnet) are successful, others are giving me a weird response:
*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\UserJW>ls
Desktop
Favorites
My Documents
Start Menu
Sti_Trace.logC:\Documents and Settings\UserJW>cd\
More?
Why is telnet giving me this "More?" response, as if expecting something?
In the code, I am simply connecting to remote CPU, logging in, and sending commands:
@connection = Net::Telnet.new(...)
@connection.login( user, pwd )
@connection.cmd(...)
Any help would be appreciated.
Thanks,
J
**EDIT:
@connection = Net::Telnet.new(
"Host" => machine,
"Prompt" => /[A-Za-z]:\\.*>\z/n,
"Timeout" => 3,
"Output_log" => output )
@connection.login( user, pwd )
@connection.cmd( 'ls' )
@connection.cmd( 'ls' )
output...
C:\Documents and Settings\UserJW>
ls
Desktop
Favorites
My Documents
Start Menu
Sti_Trace.log
C:\Documents and Settings\UserJW>
ls
More?
I can't even send more than one command, apparently. Is my Prompt regex wrong? I'm trying to allow..
C:[anything...]>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题与你( ruby telnet to windows 2008 ,execute command错误)。我解决了。原因是 ruby net/telnet 库使用错误换行符。必须是 EOL(CR+LF) 但 CR+NULL 。但我不知道bug是谁制造的,windows还是ruby?我写了一个猴子补丁如下:
I meet a same problem with you ( ruby telnet to windows 2008 ,execute command error ).I solved it. the reason is ruby net/telnet library use error newline seperator. Must be EOL(CR+LF) but CR+NULL . But I don't know who make the bug,windows or ruby? I write a monkey patch as below: