From: Stu Date: 2013-05-08T11:14:11+09:00 Subject: Re: File Problem with pty and irb Hi Bill You can use the backticks which just call sh -c fifo = `cat /tmp/fifo` or the c style popen which is the same: fifo = IO.popen 'cat /tmp/fifo' do |p| p.readlines end puts fifo or use the File pointer syntax which removes the need to call the shell and saves a kitten: File.open '/tmp/fifo', 'r' do |f| f.readlines end You'll also want to consider creating a trap to clean up the fifo if an interupt signal is sent or when the program receives hup. popen would also be appropriate for creating the mycode redirect to pipe process and more importantly could be done without the named pipe as well and done completely internally from within ruby's IO and Kernel methods. In fact ruby has IO.pipe which is probably what your looking for. On Tue, May 7, 2013 at 6:46 PM, Admin Tensor wrote: > Hi, > > I have a C code that writes to a fifo file (a named pipe), and when I > just run it directly, it is fine: > > Screen 1: ./mycode > (running) > > Screen 2: cat < namedpipe > (a lot of outputs) > > But when I try to run it via irb, it doesn't give me the output: > > Screen 1: irb -r cmd.rb > irb(main):001:0> > (the code is running in the background) > > Screen 2: cat < namedpipe > (nothing) > > and cmd.rb is basically > > require 'pty' > @rbOut, @rbIn, @pid = PTY.spawn('mycode') > > It looks that the code is running, because I can give the command in > Screen 1 and the results are fine and indicate progress. Is there any > way to make mycode to output to namedpipe under irb? Thanks. > > Best regards, > > Bill > > -- > Posted via http://www.ruby-forum.com/. >