How to run shell commands within python

Fredrik Lundh fredrik at pythonware.com
Thu Feb 16 03:08:22 EST 2006


"fileexit" wrote:

> thanks... i was to hasty to post this question, i found a good answer
> here:
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffdab847125f81b6

that's an old thread, and Python has grown a few more ways to
deal with shell commands since then.  if os.system isn't good en-
ough for you, subprocess is the preferred alternative:

    http://www.python.org/doc/lib/module-subprocess.html

(also note that most trivial shell commands are better done in
python.  most uses of cat, for example, can be trivially emulated
with one or two lines of python...)

</F>






More information about the Python-list mailing list