Newbie question...

Ken Kinder ken at _nospam_ken.x13.com
Wed May 26 01:12:49 EDT 1999


Christian Tellefsen wrote:
> 
> ... I just started programming in Python (today!)
> 
> I want to run a few OS commands from python (on Win NT),
> but I cannot find a way to wait for the commands to finish.
> 
> Source:
> **
> os.system ('c:\ntreskit\sc stop "' + serviceA + '"')
> os.system ('c:\ntreskit\sc stop "' + serviceB + '"')
> os.system ('c:\ntreskit\sc stop "' + serviceC + '"')
> **
> 
> Is there a way I can ensure that each command finishes before the next line
> in the script is executed?
> 
> Sorry if this has been asked before!

Good question.  Yes, there is.  Do it just how you had it.  os.system
returns with exit code of the command you exited, in both *nix and
Windows - that's how the C system call works, and this is just a thin
wrapper.




More information about the Python-list mailing list