calling a program without waiting for it to finish

Peter Hansen peter at engcorp.com
Mon Mar 17 09:04:20 EST 2003


mnietz wrote:
> 
> Hey Guys,
> 
> I looking for a way to execute a command-line programm from Pyhton
> without having to wait for it to finish.
> AFAIK i can't use os.popen() or os.system() because these methods wait
> for a return-value. Or can I use the unix command exec in way like
> start in windows os.system("start ping -t www.google.com")?
> That does exactly what i need.

Under Linux, appending an ampersand to the end of the command should
do roughly what you want, shouldn't it?

  os.system("ping -blah -blah www.google.com &")

(Of course, pinging something without checking the return value 
sounds pretty much useless to me, but maybe you were just giving
a contrived example.)

-Peter




More information about the Python-list mailing list