On 12/20/06, Simon Strandgaard <neoneye / gmail.com> wrote: [snip] > I want to listen for: > 'Enter passphrase: ' > 'Repeat passphrase: ' > eof? [snip] Ok I got a partial solution.. now it would be nice if I could access the string accumlated in readlines when this thing timeouts. -- Simon Strandgaard File.open("test", "a+") do |f| 500000.times { f.write("helloworld") } end require 'expect' require 'timeout' require 'pty' timeout(3) do PTY.spawn("gpg -c test") do |r,w,pid| w.sync = true r.expect("Enter passphrase: ", 1) do |e| raise unless e w.puts "secretpassword" end r.expect("Repeat passphrase: ", 1) do |e| raise unless e w.puts "secretpassword" end r.readlines puts "eof=#{r.eof}" end end system('ls test*')