[Python-bugs-list] redirected stdout under Windows NT (PR#165)
Guido van Rossum
guido@CNRI.Reston.VA.US
Tue, 21 Dec 1999 11:47:12 -0500
> I have troubles running Python scripts from command line. The script
>
> print "Hello"
>
> works fine if ran as
>
> test.py
>
> However, if I run it as
>
> test.py >test.txt
>
> The test.txt is empty (0 bytes), and no console output.
>
> I did not see similar behavior in 95.
>
> In addition, sys.stdout.fileno() is -1 for redirected file which does not look
> right.
This is a problem in Windows -- I/O redirection doesn't always work as
expected, depending on how your script is invoked.
See Python FAQ 8.14 for various work-arounds:
http://www.python.org/cgi-bin/faqw.py?req=show&file=faq08.014.htp
--Guido van Rossum (home page: http://www.python.org/~guido/)