From: "Y. NOBUOKA" Date: 2011-04-08T17:03:13+09:00 Subject: Re: reading and writing to child process with streams in ruby Hi, Using IO#readpartial [1] instead of IO#read, you'll see the ruby script run as expected. However, I don't know if this is the best way or not. [1] http://www.ruby-doc.org/core/classes/IO.html#M000917 ---------------------------------------------------------------------- ruby script ---------------------------------------------------------------------- require 'open3' cmd = "./myScript.bash" #cmd = "gpg --list-keys" begin stdin, stdout, stderr = Open3.popen3 cmd p stdin, stdout, stderr done = 0 until done == 1 begin # using IO#readpartial instead of IO#read line = stdout.readpartial( 4096 ) puts "#{line}" puts line.eql?("username: ") if line.eql?("username: ") puts "myuser" stdin.write "myuser\n" # using IO#readpartial instead of IO#read line = stdout.readpartial( 4096 ) if line.eql?("password: ") puts "mypassword" stdin.write "mypassword\n" done = 1 end puts "im here!" end rescue => err p err end end end -- 信岡 裕也 (NOBUOKA Yuya)