From: 7stud -- Date: 2008-05-19T16:27:13+09:00 Subject: Re: Needing to pipe commands to automate program 7stud -- wrote: > This works too: > > #original program: r1test.rb > > puts "Enter 32 or 64 bit:" > answer1 = gets.strip.chomp > > puts "Enter the path where you wish to install:" > answer2 = gets.strip.chomp > > File.open('output.txt', 'w') do |f| > f.puts("Your answers were:") > f.puts answer1 > f.puts answer2 > end > > Just be aware that popen() hijacks stdin and stdout in the original > program--directing the original program's input and output to the IO > object created in the driver program. If your original program writes > some results to a file, then that won't be an issue. Whoops. Here's the driver program: #driver program: pipe = IO.popen("ruby r1test.rb", "w+") f = File.open("data.txt") pipe.puts(f.gets.chomp) pipe.puts(f.gets.chomp) puts puts "Hit enter to end program" gets -- Posted via http://www.ruby-forum.com/.