On 2006-04-21, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> hi
> i wanted to start execute a command and put it in the background. i am
> using Unix.

If you use subprocess, or even os.spawn, it should be portable and work
on all systems (although the docs list some restrictions).

> Usually i start this command using something like this :
> "/path/somecmd  &" with the "&" to put it to background.

You can still do that: os.system("/bin/mycmd &"), or use
subprocess.Popen with True in its shell parameter. os.system invokes the
shell, so this is not portable-- you must have a shell in which & means
what you want (it works at least on bash and probably on some other Unix
shells).

> i looked at the subprocess module docs and came across this statement
> Replacing os.spawn*
> -------------------
> P_NOWAIT example:
> pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")
>==>
> pid = Popen(["/bin/mycmd", "myarg"]).pid
>
>
> Can i ask if P_NOWAIT means the same as "&" ?? so if it is, then  this
> statement

I think it does.

> pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")
>
> will put mycmd into background and return to the caller...?

Should do.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to