473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem: Windows Command line Pipe to stdin

Python 2.3 on Windows XP

The following works when run from the command line.

import sys

text = sys.stdin.read()
# do something on the text
# ...
sys.stdout.write(text)

But if the above code is used as a filter program that gets another programs
output as shown below, it fails as shown.

C:\>textGen.py | filter.py

Traceback (most recent call last):

File "C:\filter.py", line 4, in ?

text = sys.stdin.read()

IOError: [Errno 9] Bad file descriptor

Any ideas on what is happening and how to fix it?
Oct 30 '05 #1
1 6032
On Sun, 30 Oct 2005 16:40:10 -0500, "GerShar"
<ge************@sympatico.ca> declaimed the following in
comp.lang.python:
C:\>textGen.py | filter.py

Traceback (most recent call last):

File "C:\filter.py", line 4, in ?

text = sys.stdin.read()

IOError: [Errno 9] Bad file descriptor

Any ideas on what is happening and how to fix it?

How to fix? First step, you drop a nuke in Washington (state); that
should get Bill Gates even if he is in his underground mansion.

Second step, you run when Linux takes over the big gap that results.
Barring all that... Try using:

....> python textGen.py | filter.py

I have vague recollections that the command shell in Windows has some
flaw when it runs an application that requires loading an interpreter
AND doing I/O redirection.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Oct 31 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: MarkE | last post by:
I'm sure someone else has posted a similar problem but I can't find it, nor the solution... I have a python script which accepts a command line argument. E.g. python.exe myscript.py -n Foo I...
3
by: Glenn | last post by:
We want to deploy a change to a database with minimal effort by the users. I see how to open an Access database from the command line, but can you then issue DDL statements through a command line? ...
1
by: Ernesto | last post by:
I'm looking for a way to capture command line output from a cmd session. Is there a way to use python to launch the application from the beggining.... then stream all of the output to a text...
7
by: John F | last post by:
Not exactly a C question (sorry), but I couldn't find a ng that seems more suitable... On the Unix shell command line I can successfully write cc -DPATH=\"abcd/\" program.c -o program to...
5
by: vjonweb | last post by:
Hello! I am facing an extremely frustrating problem with command line arguments...I have no clue why it is happening. Any help will be greatly appreciated. My program: "a.c"...
10
by: olafilink | last post by:
Hello, we're running an Win2003server with IIS6 and PHP4 in fastCGI config. When i try to use system() command to execute ffmpeg.exe it works ok when i run the PHP script from the commandline on...
17
by: Matt | last post by:
Hello. I'm having a very strange problem that I would like ot check with you guys. Basically whenever I insert the following line into my programme to output the arguments being passed to the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.