Std. IO streams in Ruby

Jatin Kumar
2010-08-01T18:29:57Z

In my rails controller, I am doing the following :

@output = `g++ j.cpp -o "prog" && ./prog`

This gives the output in the @output variable which i can display in my
view. But the above works only if the j.cpp is correct and doesn''t
expect any user input. How can I use the stdin/stderr and stdout streams
here so that :

If the user has to give input, I open a dialog box on the view with a
textfield where he/she can enter the input, and the program continues to
execute.
If there are any errors in the file, then I should be able to get the
errors and display them to the user.
I tried doing this :

@output = `g++ j.cpp -o "prog" && ./prog| tee prog`

This allows me to enter the user input at the server command prompt (the
server log...i don''t know what do we call it), but I want it to be
entered in a textfield in the view.

In short, how can I get control of stdin, so that whenever the stdin
waits for some user input, i get to know that it is waiting for the user
input and then i can show the user a text field and get the user input
to be passed in the stdin stream.
Let me know if there''s a doubt in the question.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org