os.popen: writing to...?

David Bolen db3l at fitlinxx.com
Tue Feb 13 22:54:44 CET 2001


Sean Laurent <slaurent at sonicfoundry.com> writes:

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

One way I've been able to replicate this behavior (under NT, not 2000)
is if the process I've started exits before I get around to the
write().

Are you sure that "p4" is still running on your system at the point
when you try to do the write?  Could there be something wrong with the
options you are supplying or just something about running p4 in a
child process that is causing it to terminate early?

Or is it possible that the child shell can't find p4 in the path or
something?  In such a case, you might try reading first from instream
to see the pipe is closed, or if you use popen3, checking the stderr
handle to see if there is an error message from your shell.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list