Windows DOS box redirection (was: Code not work - DESPERATE HELP)

Bill McClain 20080915.20.wmcclain at spamgourmet.com
Fri Oct 31 08:06:30 EDT 2008


On 2008-10-31, Glenn Linderman <v+python at g.nevcal.com> wrote:

> The problem with stdin/stdout is on Windows 2000 (and maybe the earlier 
> NT?).  But not on XP or AFAIK Vista.

> It only occurs when a program is executed indirectly using the file 
> associations instead of directly via the command line.

> File associations, are the Windows "let's do it a different way" 
> alternative for Unix she-bang lines (#!/path/to/python).

Can you elaborate on this? I have some very simple command-line utilities I
would like to make available on different platforms, but what little I knew
about Windows is fading into the past.

This example:

    import sys
    print sys.stdin.read()

...works in the Windows XP dos box if I do:

    python demo.py < file.txt

...but I get the error 9 for:

    demo.py < file.txt

Is there any way to make the second version work on Windows?

-Bill
-- 
Sattre Press                                The King in Yellow
http://sattre-press.com/                 by Robert W. Chambers
info at sattre-press.com         http://sattre-press.com/kiy.html



More information about the Python-list mailing list