Programmatically Getting Process ID

Hernan M. Foffani hernanf at my-deja.com
Fri Mar 3 18:33:11 EST 2000


Samuel A. Falvo II wrote:
> Is there a way that I can programmatically obtain a process ID for a
> particularly named process?
The portable way to do it (in UN*X, I mean) is to run a script and get
the output (via pipes), something like:

#!/bin/sh
ps -ef | grep "$1" | grep -v grep | awk '{ print $1 }'

If you know in advance which daemons you are trying to kill, some of
them leave a text file with the running pid. Just read it.

Regards,
-H


--
Hernán Martínez Foffani
hernanf at my-deja.com


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list