ruby中使用NET/TELNET类的问题
大家好, 我正在使用 ruby 中的“net/telnet”类远程登录一台机器,但遇到了一些starnge问题...这是我的代码
require 'net/telnet'
ip="192.168.247.111"
localhost = Net::Telnet::new("Host" =>ip,
"Timeout" => 50,
"Prompt" => /[$%#>] \z/n)
localhost.login("root", "root") { |c| print c }
现在,当我运行上面的代码时,我收到了类似的错误
c:/ruby/lib/ruby/1.8/net/telnet.rb:352:in `initialize': getaddrinfo: no address
associated with hostname. (SocketError)
,但如果我对IP地址进行了编码就像“主机”=> “192.168.247.111”
能够使其工作意味着能够远程登录到机器...但我的要求是从某个变量分配...我怎样才能实现它?
Hii all,
I am telneting a machine using "net/telnet" class that comes in ruby but am having some starnge problem...This is below code i have
require 'net/telnet'
ip="192.168.247.111"
localhost = Net::Telnet::new("Host" =>ip,
"Timeout" => 50,
"Prompt" => /[$%#>] \z/n)
localhost.login("root", "root") { |c| print c }
Now when i run the above code i got en error like
c:/ruby/lib/ruby/1.8/net/telnet.rb:352:in `initialize': getaddrinfo: no address
associated with hostname. (SocketError)
But if i harcoded th Ip address like "Host"=> "192.168.247.111"
am able to make it work means able to telnet to machine...but my requirement it to assign from some variable ....How could i achieve it??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this: