Ruby, Как я могу получить доступ к локальным переменным вне цикла do - end

У меня есть цикл, в котором я выполняю серию команд на удаленной машине:


   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

Буду признателен за любую помощь. Спасибо,

Привет, Йорг!

Я реализовал ваши предложения, но теперь получаю сообщение об ошибке:


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
5
задан kamal 27 September 2010 в 16:47
поделиться