From: Xeno Campanoli Date: 2008-05-31T06:37:11+09:00 Subject: Re: getting standard error and output from ruby script in real time Stefano Crocco wrote: > I'm trying to write an editor for ruby in ruby using the KDE4 bindings for > ruby and I'm facing a problem which I don't know whether is caused by ruby or > by KDE. I want my editor to be able to run a ruby script and display both the > error messages and the normal output in a window. The problem is that all the > text sent to the standard output seems to be received together from my > application, and so does the text sent to standard error, even if the two are > mixed. For example, when I run the following script > > 5.times do |i| > warn "Warning #{i}" > puts i > end > > the output window of my program displays this: > Warning 0 > Warning 1 > Warning 2 > Warning 3 > Warning 4 > 0 > 1 > 2 > 3 > 4 > > instead of this (which is what I get if I run the script from terminal) > Warning 0 > 0 > Warning 1 > 1 > Warning 2 > 2 > Warning 3 > 3 > Warning 4 > 4 > > Since I don't have much experience on interprocess communication, I can't, as > I said, understand if this issue is due to the way ruby prints its output or > to the tools I use to run the ruby script from my editor, which are specific > of KDE. I'd be glad if someone could give me a hint on this, so that at least > I can know whether I have to look for documentation about ruby or about KDE. > > Thanks in advance > > Stefano > > STDERR.puts puts is stdout.