From: ientu Date: 2005-10-14T00:26:53+09:00 Subject: exec and pipe 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') } # Process.waitpid(pid,0) # do not wait for the process to terminate # read output in real time writeme.close while readme.gets do puts 'processing: ' + $_ ... end This doesn't work, apparently when I run 'exec' STDOUT is reopened and I get the output from the perl script on screen. What am I doing wrong? Is this the right approach? Many thanks /giulio