command line of a process.exe on another host

Giampaolo Rodola' gnewsg at gmail.com
Fri Jun 12 06:47:53 EDT 2009


On 12 Giu, 00:18, "Harry" <h... at pillai.co.uk> wrote:
> HI ,
> I have number of process run on different windows servers which run's with
> different command line parameters. for example "process.exe -input<ddd>
> statusurl:http://sss.com"., These parameters can vary from host to host.
> using Psexec I know the PID and process name which are running on these
> machines, but how I can read the command line parameters of these process.
> Is there a way to read these command line of the proess via python pls?
>
> any feedback appreciated..
>
> thanks
> Hari

You can easily do this with psutil [1]:


>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.cmdline
['/usr/bin/python2.4']
>>>


Since psutil uses the native Windows calls to retrieve such kind of
info it's a lot faster than using any WMI-based solution.


[1] http://code.google.com/p/psutil/



--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil



More information about the Python-list mailing list