tags:

views:

39

answers:

4

Im running this command from ruby script:

system "trad install"

This will prompt me three times for choosing y/n.

Is there a way to automatically choose y,y,n?

A: 

well, you might want to use

pipe = IO.popen("trad install")
pipe.write "yyn"

Not sure if that works, however.

Tass
it gave me error: `write': not opened for writing (IOError)
never_had_a_name
A: 

I don't think you can do that. If trad is your application, the best way is to add options to it.

Dmitry Maksimov
It isnt my app :)
never_had_a_name
+1  A: 

You can probably automate a run with Session and Ruby's built-in pty/expect (which seems to have no online documentation). (Dave Thomas has a few brief examples of expect and pty in recent editions of Programming Ruby, if you have a copy of that.)

However, I agree with Dmitry: it's almost certainly easier to adjust trad if possible.

Telemachus
I think expect is what you want to try.
Jason Noble
+2  A: 
echo -e "Y\nN\nN\n" | trad install
Teodor Pripoae
Great answer and simple answer! :)
never_had_a_name