470,849 Members | 1,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Running Python scripts under W2K with I/O redirection

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:\> pyscript.py file.inp

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

However if I enter commands like:

H:\> type file.inp | pyscript.py

or

H:\> pyscript.py < 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 pyscript.py

or

H:\> python pyscript.py < 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

Jul 19 '05 #1
1 1608

<su********@yahoo.com> schrieb im Newsbeitrag
news:11**********************@g49g2000cwa.googlegr oups.com...
|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:\> pyscript.py file.inp
|
| and that's what I get. All ok so far.
|
| However if I enter commands like:
|
| H:\> type file.inp | pyscript.py
|
| or
|
| H:\> pyscript.py < 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 pyscript.py
|
| or
|
| H:\> python pyscript.py < 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.

Your suspicion is correct

see:

http://support.microsoft.com/default.aspx?kbid=321788

--

Vincent Wehren

|
| 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
|
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rolfe | last post: by
4 posts views Thread by Peter Otten | last post: by
53 posts views Thread by Michael Tobis | last post: by
6 posts views Thread by Ishpeck | last post: by
24 posts views Thread by Mark | last post: by
3 posts views Thread by koutoo | last post: by
1 post views Thread by Michael Torrie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.