you can get the best result in python as below:
linux :
import sys, os f = os.popen("top -p 1 -n 1", "r") text = f.read() print text
update
windows :
from os import popen from sys import stdin ps = popen("C:/WINDOWS/system32/tasklist.exe","r") pp = ps.readlines() ps.close()
source share