os.popen: writing to...?

Sean Laurent slaurent at sonicfoundry.com
Tue Feb 13 19:13:58 CET 2001

On Wed, 31 Jan 2001 19:42:23 GMT, James Lockley
<poseidon_cma at my-deja.com> wrote:

>i now want to go to the next step and get rid of the batch files...
>i need to open a pipe to a command and then write the command arguments
>to it.
>as far as i could make out, this should work:
>>>> abaqus='c:\\abaqus\\5.8-14\\abaqus.exe'
>>>> abq=os.popen(abaqus,'w')
>>>> abq.write('post')
>but i get this:
>Traceback (innermost last):
>  File "<interactive input>", line 1, in ?
>IOError: [Errno 22] Invalid argument

Hrmmm.  I have been encountering the exact same problem under Windows

I have tried all the flavors of os.popen ... os.popen(), os.popen2(),
os.popen3() and os.popen4().  I have also tried the popen2 flavors eg.
popen2.popen2(), popen2.popen3(), and popen2.popen4().  None of them
seem to work...

>>> instream, outstream = popen2.popen2("p4 -x - edit")
>>> instream
<open file 'p4 -x edit', mode 'r' at 017A1C88>
>>> outstream
<open file 'p4 -x edit', mode 'w' at 017A1CB0>
>>> outstream.write('d:\\install\\proj\\projects.xml\n')
Traceback (innermost last):
  File "<interactive input>", line 1, in ?
IOError: [Errno 22] Invalid argument

Does anyone have any bright ideas or suggestions?


More information about the Python-list mailing list