Programmatically Getting Process ID

Hernan M. Foffani hernanf at my-deja.com
Sun Mar 5 11:59:23 EST 2000


I wrote:
> ... something like:
> >#!/bin/sh
> >ps -ef | grep "$1" | grep -v grep | awk '{ print $1 }'

Samuel wrote:
> ...
> On _my_ Linux distribution, the awk statement should read '{ print $2
}'
> instead of $1.  I'm not sure about how well this would work on a non-
Linux
> system.

You are right. I should have added "(untested)" to the "something like".
On Linux (and related cousins/friends) you can use the /proc filesystem
solution posted by Justin et al.

Regards,
-H



--
Hernan Martinez 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