By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,923 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,923 IT Pros & Developers. It's quick & easy.

Running Python scripts under W2K with I/O redirection

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a

<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.