On Jan 17, 2008 10:41 PM, Daniel Aquino <mr.danielaquino at gmail.com>
wrote:> I have created a little mock example below.
> When I run this little script I see the output.
> But when I run it like, "ruby mock.rb > output",
> I get no output on the console or in the file!!!
>
> What gives?
>
> Thanks...
>
> ------------------------------
> #!/usr/bin/env ruby
> require ''rubygems''
> require ''eventmachine''
> EM::run {
> puts "bla bla bla bla"
> }
> ------------------------------
The problem you''re seeing is related to output buffering, and has
nothing to do with EM at all. Output to a file is buffered by default
unless you declare otherwise.
If you want your output to be unbuffered, place a STDOUT.sync = true
before the puts call, or, to flush the buffer manually, place a
STDOUT.flush after the puts call.
Best regards,
--Michael