title: Ruby, How can i access local variables outside the do - end loop
body: <p>I have a loop where i execute a series of command on a remote machine:</p>
  
  <pre><code>
     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
  </code></pre>
  
  <p>i want to access #{stream} and data outside the do-end loop</p>
  
  <p>I would appreciate any help.
  Thanks,</p>
  
  <p>Hi Jörg,</p>
  
  <p>I implemented your suggestions, but now i am getting error:</p>
  
  <pre><code>
  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
  </code></pre>