G
GerShar
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?
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?