我有一个循环,在远程计算机上执行一系列命令:
ssh.exec('cd /vmfs/volumes/4c6d95d2-b1923d5d-4dd7-f4ce46baaadc/ghettoVCB; ./ghettoVCB.sh -f vms_to_backup -d dryrun') do|ch, stream, data|
if #{stream} =~ /vmupgrade/
puts value_hosts + " is " + data
puts #{stream}
puts data
end
end
我想访问 #{stream} 和 do-end 循环之外的数据
我将不胜感激任何帮助。
谢谢,
Hi Jörg,
我实施了您的建议,但现在出现错误:
WrapperghettoVCB.rb:49: odd number list for Hash
communicator = {ch: ch, stream: stream, data: data}
^
WrapperghettoVCB.rb:49: syntax error, unexpected ':', expecting '}'
communicator = {ch: ch, stream: stream, data: data}
^
WrapperghettoVCB.rb:49: syntax error, unexpected ':', expecting '='
communicator = {ch: ch, stream: stream, data: data}
^
WrapperghettoVCB.rb:49: syntax error, unexpected ':', expecting '='
communicator = {ch: ch, stream: stream, data: data}
^
WrapperghettoVCB.rb:76: syntax error, unexpected kELSE, expecting kEND
WrapperghettoVCB.rb:80: syntax error, unexpected '}', expecting kEND