From: Ruggershawn Date: 2008-05-23T06:25:03+09:00 Subject: Re: Needing to pipe commands to automate program Hey Thanks for the reply! It worked great! Now I am wondering how to output the standard out to the screen? Right now I run my ruby program and cant see anything being logged. On May 19, 1:27 am, 7stud -- wrote: > 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 viahttp://www.ruby-forum.com/.