[Tutor] reading from redirected standard input on windows

Magnus Lyckå magnus@thinkware.se
Thu May 29 16:39:10 2003


At 16:33 2003-05-29 +0100, sean@odonnell.nu wrote:
>I'm attempting to write a script than can read redirected input.
>
>e.g.   if you run
>
>echo xxxxxx | testread.py
>
>it should be able to read the string xxxxxx.
>
>I've tried using stdin , with no sucess , the script still waits
>for keystrokes. Anyone have any ideas? or know if this is even possible in
>windows???

In MS Windows this won't work, since the default mechanism for
connecting extensions to programs doesn't handle pipes. You have
to write:

echo xxxxxx | python.exe testread.py

If you desperately want it to work as it *should* in Windows, use
bash instead of cmd.exe/command.com. If you have echo on your computer
you might have a real shell as well...


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program