[Tutor] XP & catching execl o/p ?

Tim Golden Tim.Golden at viacom-outdoor.co.uk
Wed Dec 6 13:00:17 CET 2006

[Dave S]

| Just looked at WMI - didn't know it existed !
| Am going down the subprocess route first as its 'built in'. 
| If that does not work - hello WMI

Personally, I find having both (and other) tools
in my toolbelt useful -- I've just answered another
question elsewhere about starting and stopping
a process on Win32 using the pywin32 win32process
module, so that's another option...

Generally subprocess is the recommended approach
these days because it's specifically designed to
superseded the various popen/spawn/system choices
previously available. The only problem is that its
general-purpose nature means fossicking around to
mimic the relative simplicity of os.popen:

import os

pipe = os.popen ("tasklist")

# skip unwanted headers
pipe.readline ()
pipe.readline ()
pipe.readline ()

for line in pipe.readlines ():
  print line.split ()[0]



This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Tutor mailing list