popen4 doesn't block?

Donn Cave donn at u.washington.edu
Fri Jan 24 19:20:12 EST 2003


Quoth Terry Hancock <hancock at anansispaceworks.com>:
...
| Which I *could* translate into python (with os.* calls), but would rather 
| leave as a shell script, since it's simpler that way.  So I have a data 
| structure in Python that defines my package and includes this script as a 
| string.  I then run the script using os.popen4, like this:
|
| i1f, o1f = os.popen4('tcsh')
| i1f.write(script)
| i1f.close()

I don't know that it will solve your problem - doesn't seem to
happen to me - but it would be simpler in some ways if you could
bring yourself to write the script out to disk and then invoke it
by file name.  Eliminates a pipe, and a potential deadlock with it.
Secondly, I think you would be better off to use 'sh' as the shell
(and of course use Bourne shell syntax in the shell commands --
">& megane.log" -> "> megane.log 2>&1".)  sh is universally supported
on UNIX and similar platforms, and it's ordinarily better software
than tcsh for anything but interactive use (if that.)

	Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list