Getting pid of a remote process

srinivasan srinivas sri_annauni at yahoo.co.in
Tue Aug 19 06:37:28 EDT 2008


Thanks a lot.
But i am wondeing will it return correct pid if more than one instance of <scriptname> run on the remote machine??
Thanks,
Srini



----- Original Message ----
From: Diez B. Roggisch <deets at nospam.web.de>
To: python-list at python.org
Sent: Tuesday, 19 August, 2008 2:54:52 PM
Subject: Re: Getting pid of a remote process

srinivasan srinivas wrote:

> This is wat i am doing :
> 
> args = [ "SSH", <hostname>,  <script_name>]
> I am giving this to subprocess.Popen()
> Thanks,
> Srini

Then the answer is simple: how would you figure out the remote process pid
using ssh? Once you found that out, pass that to Popen. Make sure you
capture stdout of the Popen-class to get the answer.

Something like

ps aux | grep <script_name> | grep -v grep | awk '{print $2}'

should be the command.

Diez
--
http://mail.python.org/mailman/listinfo/python-list


      Cricket on your mind? Visit the ultimate cricket website. Enter http://in.sports.yahoo.com/cricket/



More information about the Python-list mailing list