Forcing STDOUT.sync for scripts

I’m trying to figure out a way to force STDOUT to be synchronized when
I run scripts with Ruby. I’m using emacs and MKSNT on Windows XP, and
I can’t see the output (nor give input) when I run things like the
generate script for Rails, the WEBrick server, etc. because output is
buffered.

I tried putting -e “STDOUT.sync = true” before my script invocation,
but it looks like Ruby doesn’t run a given script file if the -e is
given. Boo.

Does anyone know a way to fix this? I can run the scripts outside of
emacs, but it’s a real pain…

Frayzhe

Frayzhe wrote:

Does anyone know a way to fix this? I can run the scripts outside of
emacs, but it’s a real pain…

How about creating a “sync.rb” file in your site-ruby folder, then:

ruby -rsync myscript.rb

?

daz

daz schrieb:

How about creating a “sync.rb” file in your site-ruby folder, then:

ruby -rsync myscript.rb

It would be great either to:

  1. ship such a module with ruby

or to

  1. provide a command line option such as python’s:
    “-u: unbuffered binary stdout and stderr”

This feature is often required, such as running a script in any IDE.

Cheers,
Paulus

You could always build your sync.rb file and add it to your RUBYOPT env
variable …

j.

On 11/27/05, Paulus E. [email protected] wrote:

or to


“Remember. Understand. Believe. Yield! → http://ruby-lang.org

Jeff W.

Paulus E. schrieb:

or to

  1. provide a command line option such as python’s:
    “-u: unbuffered binary stdout and stderr”

This feature is often required, such as running a script in any IDE.

Hi Paulus,

another way is use a command line such as

ruby -e “STDOUT.sync = true” -e “load ARGV.shift” myscript.rb

Regards,
Pit

Frayzhe schrieb:

This last suggestion would be great, but it doesn’t work. Ruby doesn’t
run the script given at the end of the command line if you have one or
more -e switches. This, too, seems like something that could/should be
changed…

Have you tried the command line I’ve shown?

Regards,
Pit

This last suggestion would be great, but it doesn’t work. Ruby doesn’t
run the script given at the end of the command line if you have one or
more -e switches. This, too, seems like something that could/should be
changed…

Frayzhe

Hi,

At Mon, 28 Nov 2005 16:51:38 +0900,
Pit C. wrote in [ruby-talk:167734]:

another way is use a command line such as

ruby -e “STDOUT.sync = true” -e “load ARGV.shift” myscript.rb

It’d be better to set $0 too.

 ruby -e STDOUT.sync=true -e 'load($0=ARGV.shift)' myscript.rb

nobuyoshi nakada schrieb:

At Mon, 28 Nov 2005 16:51:38 +0900,
Pit C. wrote in [ruby-talk:167734]:

another way is use a command line such as

ruby -e “STDOUT.sync = true” -e “load ARGV.shift” myscript.rb

It’d be better to set $0 too.

 ruby -e STDOUT.sync=true -e 'load($0=ARGV.shift)' myscript.rb

Hi Nobu,

I didn’t know you can do this. Thanks for the info! It’s very useful for
my programs.

Regards,
Pit

Pit,

Thank you! I dismissed your command line too quickly without looking
closely at what you were suggesting. Your ARGV.shift trick works
great…

Frayzhe