Getting pid of a remote process

Diez B. Roggisch deets at nospam.web.de
Tue Aug 19 05:24:52 EDT 2008


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



More information about the Python-list mailing list