Window 7 output redirection

Hi,

I have a very simple ruby script that uses puts to print to the console.

I used to be able to redirect this output using >, e.g.
d:\maven_helper>generate_dependencies.rb > pom.xml

When I run generate_dependencies it still prints the expected output to
the console, but when I redirect it, the file stays empty.

Of course I can print to the file from within ruby, but I was just
wondering why it’s not working anymore. Used the search but could not
find anything.

ruby 2.0.0p247 (2013-06-27) [x64-mingw32]

thanks,
Henrik

Subject: Window 7 output redirection
Date: mar 27 ago 13 02:30:00 +0200

Quoting Henrik Horneber ([email protected]):

I have a very simple ruby script that uses puts to print to the console.

I used to be able to redirect this output using >, e.g.
d:\maven_helper>generate_dependencies.rb > pom.xml

When I run generate_dependencies it still prints the expected output to
the console, but when I redirect it, the file stays empty.

Redirection is not done by the Ruby interpreter. In Linux, it is a
task of the shell, which collects anything that is written to file
descriptor 1 (STDOUT) by the program. I see from your syntax that you
are under windows; I have no idea about what happens there.

Carlo

Thanks for your reply. I’m aware that the redirection is a feature of
the shell, not ruby.

I used to work for me under Win XP using ruby 1.8.x.

Now it does not.

echo “something” > aFile.txt

still works though.

Anybody else using Windows 7 here?

Subject: Re: Window 7 output redirection
Date: mar 27 ago 13 02:43:52 +0200

Quoting Henrik Horneber ([email protected]):

echo “something” > aFile.txt

still works though.

If that works, it might be that you are not writing to STDOUT. You may
want to post your script… What happens if you try with a script like

STDOUT.puts(“Hello there”)

?

Carlo

Thanks again. Same thing happens when I use a probe script only
containing

STDOUT.puts(“Hello”)

File stays empty.

My script uses some require_local so I’d have to post a couple of
scripts. Also it works when not redirecting.

I’m guessing it’s something Windows 7 related.