[Tutor] XP & catching execl o/p ?

Alan Gauld alan.gauld at btinternet.com
Wed Dec 6 00:32:56 CET 2006


"Dave S" <pythontut at pusspaws.net> wrote

> Struggling with python & XP again. My app needs to know if a certain 
> program
> is running on my XP box

> os.execl('....')
> It throws the output to the terminal + I need the exact path to the 
> executable
> (a bit of a trial)

> Any ideas how I can catch the output ?

Look at the popen family of functions in the os module, and then
look at the subporocess module which supercedees them
(but the docs are expressed in tems of the oold functions!)

Use subprocess because the older popen functions don't always
work reliably on Windows - there is a separate popen as part of
the winall package, but I think subprocess.Popen works Ok.

There is more on this, including a simple example using subprocess,
in my OS topic in my tutorial.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list