how to start a new process while the other ist running on

Fredrik Lundh fredrik at pythonware.com
Wed Dec 22 02:37:55 EST 2004


Erik Geiger wrote:

> I have a running python script (capisuit incoming.py). This script shall
> start a linux shell script. If I start this script like os.system(/paht/to
> shellscipt.sh) the python scipt waits for the exit of the shell script and
> then goes on with the rest of the python script.
>
> How to start a shell script without waiting for the exit of that shell
> script? It shall start the shell script and immediately execute the next
> python command.

if you have Python 2.4, you can use the subprocess module:

    http://docs.python.org/lib/module-subprocess.html

see the spawn(P_NOWAIT) example for how to use it in your
case:

    http://docs.python.org/lib/node236.html

as others have noted, os.spawn(P_NOWAIT) can be used directly, as
can os.system("command&") (where the trailing "&" tells the shell to run
the command in the background).

subprocess is available for Python 2.2 and 2.3 as well, by the way:

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

</F> 






More information about the Python-list mailing list