process id from os.system

Rob Hooft rob at hooft.net
Mon Jul 24 03:22:35 EDT 2000


>>>>> "jv" == j vickroy <jvickroy at sec.noaa.gov> writes:

 jv> How can I obtain the process id for a program launched via
 jv> os.system (theProgram) ?

 jv> I would like to do this portability (Unix, Windows).

 jv> Presently on Unix, I'm getting the pid by parsing the output
 jv> from:

 jv>   "ps -ef | grep theProgram"

 jv> but that seems messy and unreliable since "theProgram" may be
 jv> truncated in the output from ps.

Yikes, this is not really portable across unices either.
You may want to look at my "more intelligent os.system" in the
form of the "task.py" module. This represents a subprocess of
os.system as an object. You can "Wait" for the object or "Kill"
it. Unix only.

  http://starship.python.net/crew/hooft/

Rob


-- 
=====   rob at hooft.net          http://www.hooft.net/people/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========



More information about the Python-list mailing list