channel.exec(" sudo ls -l") do |ch, success|
  abort "Could not execute commands!" unless success
  channel.on_data do |ch, data|

              channel.send_data "#{pass}\n" if data =~ /password/
          puts "#{data}"
    end
...
...

My problem is: after I executed successfully first command (ls -l), how
can I catch data, do something with it, and then execute another command
WITHOUT enter sudo password again.

Thanks all.

-- 
Posted via http://www.ruby-forum.com/.