From: Hugh Sasse Date: 2006-11-17T05:53:48+09:00 Subject: Re: testing whether a process has completed.. On Fri, 17 Nov 2006, Matthew Williams wrote: > > > I suppose > > one might look at the output of ps and see if it talks about IO, but > > then you don't know if it is scribbling exciting things on the disk > > or doing the IO that connects to you. > > I just thought this must be possible because the command prompt knows > that input is expected because it allows characters to be entered from > the keyboard, and when it is executing it blocks all input.. Are you sure it is not actually held in a buffer? What platform are you on, anyway? > > > > > Well, if you are invoking it as above, you have access to the source > > so you can get it to prompt you for input. > > OK > > > > There are exits North, East, and West. > > OK> > > > > But you have to *know* that the "OK> " is a prompt. > > require 'semiotics' # :-) > > Actually, apart from Tcl escaping, it's mostly the interaction > > that is the time consuming part of writing Expect scripts. > > You've lost me here.. i'm not a very experienced user of Ruby and am not > sure what 'Tcl escaping' or 'expect scripts' are. Could you please > explain? Tcl is another language and is the basis for Don Libes' Expect package, which handles this interaction pretty well. Tcl has a system of quoting things with [ something ] or { something } for immediate or delayed interpretation, which confuses me just too often! Ruby has Expect facilities, but I've not re-examined them very recently so am not up to speed as to how well they compare with Expect's facilities now. Should you wish to explore those other programs, which are not Ruby, then http://www.tcl.tk/ and http://expect.nist.gov/ are good starting places. > > Couldn't I just override the 'gets' method in the Ruby program and get > the new method to output something like 'WRITE', and then the Rails > program could listen for this command, and when it gets it write to the > program? Is 'gets' the only method that prompts input from the user? Yes, but as Ara said, buffering will do horrible things. You won't just get the word WRITE on it's own, almost certainly. If WRITE is all you need, then you don't need to know when to send the data to the other program. See his reply for more about that. > HTH Hugh