Returning Values from Bash Scripts

Fredrik Lundh fredrik at pythonware.com
Sun Jan 8 15:58:12 EST 2006


Steven D'Aprano wrote:

> >> How to execute bash scripts from python (other than using os.popen) and
> >> get the values that those bash scripts return.
> >
> > The easy way is to call it with subprocess.call.
>
>
> >>> import subprocess
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: No module named subprocess
>
> It might be easy, but an awful lot of people won't be using a version of
> Python that has the subprocess module, and for them upgrading may not be
> easy (or even possible) at all.

subprocess is available as a separate distribution for Python 2.2
and newer:

    http://www.lysator.liu.se/~astrand/popen5/

if you're on a unixoid system, all you need is the subprocess.py
file, which you can also get directly from the Python SVN:

    http://svn.python.org/view/python/trunk/Lib/subprocess.py

</F>






More information about the Python-list mailing list