hi all, i''m working on a rails app that calls a ruby script which writes to $stdout. i''d like somehow intercept that text and write it in realtime (usuing ajax?) to the web browser. does anyone have general (or specific) hints about how to approach this? i can''t change the code of the the called script, which is currently called using backticks. thanks for any help!! -reid --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 13 Mar 2008, at 01:31, Reid Oda wrote:> hi all, > > i''m working on a rails app that calls a ruby script which writes to > $stdout. i''d like somehow intercept that text and write it in > realtime (usuing ajax?) to the web browser. does anyone have > general (or specific) hints about how to approach this? > > i can''t change the code of the the called script, which is currently > called using backticks.Well say your script was #!/usr/bin/env puts "Hello world" Then output = `./test.rb` will set output to Hello world. You''ll only get it when the program returns. If that''s not ok, then you probably want to use IO.popen or similar and then read from the pipe it yields you. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
if i used the IO.popen method, what ajax technique could i use to get the browser to display the collected text as i gather it? On Thu, Mar 13, 2008 at 4:38 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 13 Mar 2008, at 01:31, Reid Oda wrote: > > > hi all, > > > > i''m working on a rails app that calls a ruby script which writes to > > $stdout. i''d like somehow intercept that text and write it in > > realtime (usuing ajax?) to the web browser. does anyone have > > general (or specific) hints about how to approach this? > > > > i can''t change the code of the the called script, which is currently > > called using backticks. > > Well say your script was > > #!/usr/bin/env > puts "Hello world" > > Then > output = `./test.rb` > will set output to Hello world. > > You''ll only get it when the program returns. If that''s not ok, then > you probably want to use IO.popen or similar and then read from the > pipe it yields you. > > Fred > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reid Oda wrote:> if i used the IO.popen method, what ajax technique could i use to get > the browser to display the collected text as i gather it?An iframe may be the only way. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ah yes. that''s what i want. this is my first project using AJAX, so i have a lot to learn. the text i''ll be loading into the iframe is a log file that sometimes grows as quickly as 1 line per second and other times as slowly 1 line per hour. is there a way that the rails server can tell the browser when a new line is ready to be uploaded, instead of having to check back at regular intervals? On Mon, Mar 17, 2008 at 9:12 PM, Mark Reginald James <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> > Reid Oda wrote: > > if i used the IO.popen method, what ajax technique could i use to get > > the browser to display the collected text as i gather it? > > An iframe may be the only way. > > -- > We develop, watch us RoR, in numbers too big to ignore. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reid Oda wrote:> ah yes. that''s what i want. this is my first project using AJAX, so i > have a lot to learn. > > the text i''ll be loading into the iframe is a log file that sometimes > grows as quickly as 1 line per second and other times as slowly 1 line > per hour. is there a way that the rails server can tell the browser > when a new line is ready to be uploaded, instead of having to check back > at regular intervals?An iframe would have allowed you to simply point the src parameter of the iframe to the stream and let the browser render it progressively as if it was a normal webpage. But unless there is some way to keep the loading alive (e.g. sending null characters), I fear that browsers will time-out at the 1 line/hour rate you want. So you might have to go to a more complicated AJAX polling method. Others may be able to suggest a good solution for your circumstances. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---