On Wed, 07 May 2003 20:31:39 +0900, Brian Candler wrote: > On Wed, May 07, 2003 at 06:55:54PM +0900, Simon Strandgaard wrote: >> What should I do in order to capture output to a string ??? > > You can't, in the way that you showed. You must use IO.popen as I said > before. Im no expert on this.. I don't agree.. earlier with help of the Redirector class it almost worked, except for a few glitches. I hope that some of you rubists has a nicer solution than Redirector ? Yes, I know that IO.popen can be used for capturing output from child processes. But I really want to use "system" and "backquote" :-) > The problem is this: you are forking a child process, which inherits > stdin/stdout/stderr. It then writes to them using *Unix* write() calls, to > file descriptors 1 (stdout) and 2 (stderr). > > Now, you can redirect fds 1/2 to a file before forking, in which case the > child will write to that file. But you cannot redirect those fds to a Ruby > object, because the Unix write() syscall does not call Ruby! Im no expert on this either.. thus im asking :-) VIM can execute a child process and capture its output. How does other applications do this redirection ? I cannot believe that this is NOT possible with ruby ??? [snip good technical description] > But in general, I think it's the right thing to let stderr do its job, of > giving an out-of-band error reporting channel. I want to capture all output like VIM or Emacs.. I want to do the same... I don't agree with you here ;-) -- Simon Strandgaard