getting a process's PID
Tom Plunket
tomas at fancy.org
Thu Dec 28 13:49:58 EST 2006
eldorado wrote:
> >>> g = os.popen("ps -ef | grep HUB | grep -v grep | awk '{ print $2 }'")
> >>> h = g.readlines()
> >>> g.close()
> >>> h
> ['87334\012']
> >>> h = h[:-1]
> >>> h
> []
> >>>
I understand you're probably set, but instead of using readlines() you
could also do this:
g = os....
h = g.read().split('\n')
and then your 'h' list would not have newlines.
-tom!
--
More information about the Python-list
mailing list