From: Hugh Sasse Date: 2005-10-14T00:33:05+09:00 Subject: Re: exec and pipe On Fri, 14 Oct 2005, ientu wrote: > Hi All, > > I have been coding-testing-googling all day long but I couldn't find a > solution for this. > I need to create a pipe between some ruby code and a perl script. The > perl script will be the writer: the script prints on STDOUT lines of > information at a random pace. > These lines are to be processed in ruby in real time, as soon as they > enter the pipe, without waiting for the termination of the perl script. > > Another requirement is that the perl script must be invoked from a ruby > class. > > I have tried with the following: > > readme, writeme = IO.pipe > pid = fork { > $stdout = writeme > readme.close > exec('perl some_script.pl') I think you want IO.popen for this. Two examples that worked for me: http://www.eng.cse.dmu.ac.uk/~hgs/ruby/html_spell.rb http://www.eng.cse.dmu.ac.uk/~hgs/ruby/top.rb Hugh