我已经编写了Ruby代码来将一个系统连接到另一个系统
我收到以下错误
SocketError: getaddrinfo: No such host is known.
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/t
ransport/session.rb:67:in `initialize'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/t
ransport/session.rb:67:in `open'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/t
ransport/session.rb:67:in `block in initialize'
from C:/Ruby200-x64/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from C:/Ruby200-x64/lib/ruby/2.0.0/timeout.rb:97:in `timeout'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh/t
ransport/session.rb:67:in `initialize'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.r
b:200:in `new'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.r
b:200:in `start'
from (irb):6
from C:/Ruby200-x64/bin/irb:12:in `<main>'
如何解决此错误
我的代码是
require "net/ssh"
require "net/sftp"
HOST = "192.168.2.178"
USER = "sivakumar.m"
PASSWORD = "star123"
Net::SSH.start( "HOST", "USER", :password => PASSWORD ) do |ssh|
ssh.sftp.connect
end
提前致谢。
答案 0 :(得分:3)
这是你的问题。您发送字符串名称“HOST”和“USER”而不是变量。将其更改为此
Net::SSH.start( HOST, USER, :password => PASSWORD ) do |ssh|