forcing STDOUT.sync for scripts

F

Frayzhe

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
 
D

daz

Frayzhe said:
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...


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

ruby -rsync myscript.rb

?

daz
 
P

Paulus Esterhazy

daz said:
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

2) 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
 
J

Jeff Wood

------=_Part_26474_14648322.1133155727882
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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

j.

It would be great either to:

1) ship such a module with ruby

or to

2) 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


--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org"

Jeff Wood

------=_Part_26474_14648322.1133155727882--
 
P

Pit Capitain

Paulus said:
It would be great either to:

1) ship such a module with ruby

or to

2) 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
 
F

Frayzhe

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
 
P

Pit Capitain

Frayzhe said:
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
 
N

nobuyoshi nakada

Hi,

At Mon, 28 Nov 2005 16:51:38 +0900,
Pit Capitain 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
 
P

Pit Capitain

nobuyoshi said:
At Mon, 28 Nov 2005 16:51:38 +0900,
Pit Capitain 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
 
F

Frayzhe

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,646
Members
47,254
Latest member
GayMilline

Latest Threads

Top