Redirecting stdin/stdout on Windows with '>'and '<'
Gordon McMillan
gmcm at hypernet.com
Mon Apr 10 13:32:46 EDT 2000
Mark <markmcmahon at my-deja.com> wrote:
> I seem to have a problem and can't find it in the archives or FAQ.
Not sure why not. It's come up enough times.
> I would like to redirect output of my script with '>' or '<'
>
> If I try to redirect out then the file is created but has no contents.
>
> If I try to redirect in eg...
> "test.py < autoexec.bat"
>
> I get the following traceback
>
> Traceback (most recent call last):
> File "C:\test.py", line 4, in ?
> s = sys.stdin.read()
> IOError: [Errno 9] Bad file descriptor
>
> Does anybody have an idea!!!
>
> (Windows nt 4 sp 6, python 1.52)
Apparently the bug is fixed in Win2K, but in NT and Win9x,
redirection is busted unless you spell it out:
python test.py >test.out
- Gordon
More information about the Python-list
mailing list