Execute a command on remote machine in python

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Nov 15 09:03:49 EST 2011


Martin P. Hellwig wrote:
> On 11/15/11 12:04, Roark wrote:
>> Hi,
>>
>> I am first time trying my hands on python scripting and would need
>> some guidance from the experts on my problem.
>>
>> I want to execute a windows command within python script from a client
>> machine on a remote target server, and would want the output of the
>> command written in a file on client machine. What is the way it could
>> be achieved.
>>
>
> If your doing windows to windows then you could wrap PsExec 
> (sysinternals) or the open source but more or less abandoned RemCom 
> (http://sourceforge.net/projects/rce).
>
> Disadvantage is that both of them are a royal PITA to wrap nicely.
> There are multiple problems with re-redirected STDOUT/STDERR
>
> Advantage is that you don't need to configure anything on the target 
> machine.
>
> hth
have a look at execnet

http://codespeak.net/execnet/

It allows you to execute python code on a remote machine, assuming the 
distant machine has python installed. Work fine with either nix or 
windows systems.

Regarding the file transfert, it sounds like pywin32 provides the 
netcopy service, but I'm not sure, I'm not working with windows.

JM




More information about the Python-list mailing list