Running Python scripts under W2K with I/O redirection

sub1ime_uk at sub1ime_uk at
Fri Jun 24 18:19:08 CEST 2005

I apologise if this is a well known problem. I've searched and can't
find a clear description or fix. Hope someone can help.

I am running my Python scripts under Windows 2000 using Python 2.4
Build 243 from Activestate.

If I want to specify a file as standard input to my script I can just
enter a command like:

  H:\> file.inp

and that's what I get. All ok so far.

However if I enter commands like:

  H:\> type file.inp |


  H:\> < file.inp

It doesn't work. I've also tried the variant of parsing for a command
line argument of '-' or 'filename' and then specifically either copying
the sys.stdin file object or opening the file specified, then using
that file object. Same problem.

Interestingly enough, if I specify my commands as:

  H:\> type file.inp | python


  H:\> python < file.inp

It all works the (unix-like) way I wanted it to. This leads me to
suspect there is something wrong in the way that Python is being
invoked by Windows in my problem situation rather than an inherent
fault within Python itself.

Does anyone have any idea what the problem could be and how to fix it?
I know its a really minor niggle but it'd make this poor deprived
unix-guy-forced-into-windows-servitude very happy.

Thanks,  sub1ime_uk

sub1ime_uk (at) yahoo (dot) com

More information about the Python-list mailing list