开发者

Can i Use the value of a variable from within a ruby script inside ssh.exec()

开发者 https://www.devze.com 2022-12-30 03:03 出处:网络
If i have a# {} , like#{results}, in the snippet below: results = Array.new f = open(\"/Users/kahmed/messages\", \"r\")                                 

If i have a # {} , like #{results}, in the snippet below:

results = Array.new
f = open("/Users/kahmed/messages", "r")                                  
f.each_line do |line| 
  results << "#{$.} #{line}" if line =~ /NFE/                                      
  puts #{results}
end

How can i use it in the following ssh.exec command

Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|                             开发者_Go百科 
  ssh.exec(#{results})


Something like:

Net::SSH.start( HOST, USER, :password => PASS ) do|ssh| 
  results.each{|line| ssh.exec( line)}
end
0

精彩评论

暂无评论...
验证码 换一张
取 消