From: Matthew Williams Date: 2006-11-17T06:28:42+09:00 Subject: Re: testing whether a process has completed.. > > can you state __exactly__ what you are trying to accomplish please: i > think there is a fundemental problem with your design yes. I am basically writing a web application in Rails where users can write and save ruby programs (like a Ruby IDE); then run them on the server. Obviously these programs are going to be random. I am at the stage where the user can write and save their programs onto the server, I can then run the program using: > IO.popen("ruby ruby_program.rb", "r+") do |pipe| while !pipe.eof If there is something to read from ruby_program then it can be read using: > read = pipe.gets > while read != nil > puts read <------------eventually display this in a console, print for > now read = pipe.gets end However the next stage is to detect if the program is waiting for input. I understand this is not possible, but am not sure how to go about it.. I have access to the users programs, so could insert some code into them overriding the 'gets' method, and could handle this by outputting some string i.e. 'WRITE', which the rails app could read and know then to prompt the user for input.. Example: I insert into every user program the following: > STDOUT.sync = true > def gets > write = puts "WAIT" #not sure how this would get written input from > puts "written in: #{write}" #rails program > end which is appended to this example user program, for example: > def something > puts "output" > input = gets > end > something Plausible? Are there any other methods that prompt input from the user besides 'gets' that I would need to override, or is there any other way of calling 'gets' using its class name that would bypass the overridden method? I also need to get any errors that occur and display them to the user.. I'm on a windows platform, and any help is very much appreciated.. Thank you -- Posted via http://www.ruby-forum.com/.