Brian Candler wrote:
> One other point. It's very dangerous to do
> 
>     ch.foo { |ch| ... }
> 
> because (in ruby 1.8) 'ch' is bound to the same variable in both cases. 
> That is, the value assigned to the block parameter also changes the 
> outer 'ch'. So you should call them something different.
> 

We use 1.9

> The finished program becomes:
> 
> require 'rubygems'
> require 'net/ssh'
> Net::SSH.start('localhost', 'yourname') { |ssh|
>   ssh.open_channel { |chan|
>     chan.on_request('exit-status') { |ch, data|
>       puts "process terminated with exit status: #{data.read_long}"
>     }
>     chan.exec('false') { |ch, success| puts success }
>   }
> }

Thanks! It's what I need!
-- 
Posted via http://www.ruby-forum.com/.