[Rails] Re: Re: interactive web app

Daniel N
Wed, 05 Jul 2006 14:42:06 -0000

On 7/6/06, User <exl2@cornell.edu> wrote:
>
> I do not think you can read while a file is being written to.  For
> example, I ran a program that is in an infinite loop that prints Foo,
> sleeps for 10 seconds, then prints Bar.  I redirected the output to
> log.txt.  I opened the txt file each time, and saw nothing on the text
> file.  When I abnormally closed the program, the text file had all the
> output.
>
> Mathias Wittlock wrote:
> > On 7/5/06, User <exl2@cornell.edu> wrote:
> >> but how do i redirect the stdout to a file if it is constantly
being
> >> written (the program does not end, it will keep writing to stdout
)
> >>
> >> thanks
> >>
> >
> > I believe the file gets written to while the application is running
> > (compare with logfiles). Instead of printing it in the console it just
> > writes to the file. So the file will get updated every couple of
> > seconds as the program outputs more text.
> >
> > Mathias.


Would a pipe of the binary be more appropriate?
eg foo.exe | my_ruby_script

I''m not much of a *nix user but a small ruby script that responds to
input
via a gets in a loop, and then spits out a bunch of small files with the
text from the binary for a given period of time might work.

while some_global_condition
  f = File.open( "some_file_name", "w" )
  until end_time_interval
    f << gets
    update_time_interval_condition
  end
  f.close
end

The ajax call could then remember in the session the last file name that was
read, and when a new one is available, get it and send it to the browser.

I really don''t know how this would go, and it''s quite late
here ;)

--
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...