Programmatically Getting Process ID

Samuel A. Falvo II kc5tja at garnet.armored.net
Fri Mar 3 19:21:44 EST 2000


In article <89pi3n$8lc$1 at nnrp1.deja.com>, Hernan M. Foffani wrote:
>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 }'

I just got done doing this and, unfortunately, this is not portable.  This
script will not return the PID of the process(es), but rather the user under
which the said process(es) run.

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.

Just giving you a heads up.  Thanks again for the information.  :)

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



More information about the Python-list mailing list