Return to Snippet

Revision: 21461
at December 13, 2009 21:40 by hrbrmstr


Initial Code
#!/usr/bin/python

import subprocess
import sys

bitness = 64 # default to finding 64-bit processes
bitflag = "4"

if (len(sys.argv) > 1):
        if (sys.argv[1] == "32"):
                bitness = 32
                bitflag = "0"


ps = subprocess.Popen(['ps', '-Al'], stdout=subprocess.PIPE).communicate()[0]

processes = ps.split('\n')

nfields = len(processes[0].split()) - 1

for row in processes[1:]:

    psout =  row.split(None, nfields)

    if (len(psout) > 4) and (psout[3].endswith(bitflag)) :
        print psout[nfields]

Initial URL

                                

Initial Description

                                

Initial Title
psbit.py - display apps that are either 32-bit or 64-bit

Initial Tags
python

Initial Language
Python