how can I find out the process ids with a process name
herman
Herman.Schultz at gmail.com
Sun Sep 2 15:26:27 EDT 2007
Hi,
I would like to find out all the process id with the process name
'emacs'.
In the shell, i can do this:
$ ps -ef |grep emacs
root 20731 8690 0 12:37 pts/2 00:00:09 emacs-snapshot-gtk
root 25649 25357 0 13:55 pts/9 00:00:05 emacs-snapshot-gtk rtp.c
root 26319 23926 0 14:06 pts/7 00:00:04 emacs-snapshot-gtk
stressTestVideo.py
root 26985 1 0 14:15 ? 00:00:01 /usr/bin/emacs-snapshot-
gtk
root 27472 21066 0 14:23 pts/5 00:00:00 grep emacs
and I can see the process id is 20731, 25649, etc, etc.
But now I would like to do the programmically in my python script.
I know I can use ' os.system(cmd)' to execute the command 'ps -ef |
grep emacs', but how
can I pipe the output of my 'ps -ef | grep emacs' to my python script
and then run a regression expression with it to get the process Ids?
Thank you.
More information about the Python-list
mailing list