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

Erik Geiger Erik.geiger at gmx.de
Wed Dec 22 11:10:29 CET 2004


Fredrik Lundh schrieb:

> Erik Geiger wrote:
> 
[...]
>> 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

Thats what I've tried, but it did not work. Maybe it's because I want to
start something like su -c '/path/to/skript $parameter1 $parameter2' user
I don't understand the syntax of spawn os.spawnlp(os.P_NOWAIT, "/path/to
script", "the script again?", "the args for the script?")

> 
> 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).

Thats what I've used in the Shellscript, but I haven't realized how to use
it in thy python script, thanks! :)

> 
> subprocess is available for Python 2.2 and 2.3 as well, by the way:
> 
>     http://www.lysator.liu.se/~astrand/popen5/
> 
> </F>

Erik
-- 
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen.



More information about the Python-list mailing list