Hi all,
I was doing some popen2 tests so that I'm more comfortable using it.
I wrote a little python script to help me test that (testia.py):
---------------------------------
someline = raw_input("some thing:")
if someline == 'test':
print("yup")
else:
print("nope")
---------------------------------
And another little thing that does it's popen2 stuff:
---------------------------------
import popen2
std_out, std_in = popen2.popen2(" testia.py")
x=std_out.readl ine()
print(x)
std_in.writelin es("notgood")
x=std_out.readl ine()
print(x)
---------------------------------
Now what I expected was that I got the return one the first line:
"something: " and on the second "nope", but instead of that I got:
[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
something:
Traceback (most recent call last):
File "F:\coding\pwSy nc\popen_test\p open_test.py", line 8, in ?
std_in.writelin es("notgood")
IOError: [Errno 22] Invalid argument[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
I played around a bit with flush, write and the order of first writing
and then reading, the best I can get is no error but still not the
expected output. I googled a bit copied some examples that also worked
on my machine, reread the manual and the only conclusion I have is that
I don't even understand what I'm doing wrong.
Would you please be so kind to explain my wrong doing?
(python 2.4 + win32 extensions on XPProSP2)
Thanks in advance!
--
mph
I was doing some popen2 tests so that I'm more comfortable using it.
I wrote a little python script to help me test that (testia.py):
---------------------------------
someline = raw_input("some thing:")
if someline == 'test':
print("yup")
else:
print("nope")
---------------------------------
And another little thing that does it's popen2 stuff:
---------------------------------
import popen2
std_out, std_in = popen2.popen2(" testia.py")
x=std_out.readl ine()
print(x)
std_in.writelin es("notgood")
x=std_out.readl ine()
print(x)
---------------------------------
Now what I expected was that I got the return one the first line:
"something: " and on the second "nope", but instead of that I got:
[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
something:
Traceback (most recent call last):
File "F:\coding\pwSy nc\popen_test\p open_test.py", line 8, in ?
std_in.writelin es("notgood")
IOError: [Errno 22] Invalid argument[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
I played around a bit with flush, write and the order of first writing
and then reading, the best I can get is no error but still not the
expected output. I googled a bit copied some examples that also worked
on my machine, reread the manual and the only conclusion I have is that
I don't even understand what I'm doing wrong.
Would you please be so kind to explain my wrong doing?
(python 2.4 + win32 extensions on XPProSP2)
Thanks in advance!
--
mph
Comment