I have write Ruby code to connect one system to another
我编写了Ruby代码来将一个系统连接到另一个系统
I got the following error
我收到以下错误
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>'
how to solve this error
如何解决这个错误
My code is
我的代码是
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
Thanks in advance.
提前致谢。
1 个解决方案
#1
3
Here is your problem. You are sending the string names "HOST" and "USER" not the variable. Change it to this
这是你的问题。您发送字符串名称“HOST”和“USER”而不是变量。把它改成这个
Net::SSH.start( HOST, USER, :password => PASSWORD ) do |ssh|
#1
3
Here is your problem. You are sending the string names "HOST" and "USER" not the variable. Change it to this
这是你的问题。您发送字符串名称“HOST”和“USER”而不是变量。把它改成这个
Net::SSH.start( HOST, USER, :password => PASSWORD ) do |ssh|