Re: Execute a command on remote machine in python

2011-11-15 Thread Rodrick Brown
You could easily script this with popen calling secure shell to execute a 
command and capture the output.  

Sent from my iPhone

On Nov 15, 2011, at 7:04 AM, 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.
> 
> 
> Thanks in advance,
> Roark.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Execute a command on remote machine in python

2011-11-15 Thread Marco Nawijn
On Nov 15, 1:04 pm, 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.
>
> Thanks in advance,
> Roark.


Hello Roark,

If the command does not change over time, an option could be to
encapsulate the command and the output behind an XML-RPC interface. I
used it several times now and for me this works perfectly. XML-RPC is
part of the Python standard library, so it should work out of the box
on windows and linux. It also supports mixed programming languages
(maybe C# on windows to get the info you want and python on linux on
the client).

Kind regards,

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


Re: Execute a command on remote machine in python

2011-11-15 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> On Tue, Nov 15, 2011 at 11:04 PM, Roark  wrote:
> > Hi,
> >
> > 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.
> 
> This looks like a job for SSH.

You might also want to look at fabric (http://fabfile.org).  It's a nice 
python library for remote command execution built on top of SSH.

A more general answer is that, yes, SSH is the right thing to be looking 
at for your basic connectivity, data transport and remote command 
execution.  But trying to deal with raw SSH will drive you batty.  
Something like fabric, layered on top of SSH, will make things a lot 
easier.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Execute a command on remote machine in python

2011-11-15 Thread Xavier Ho
It sounds like Fabric is what you're after. We use it at work and it's the
best thing since ssh. ;]

http://docs.fabfile.org/en/1.3.2/index.html

(Actually, it uses ssh internally and allows you to do remote shell-like
programming in a pythonic fashion.)

Cheers,
Xav



On 15 November 2011 22: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.
>
>
> Thanks in advance,
> Roark.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Execute a command on remote machine in python

2011-11-15 Thread Chris Angelico
On Tue, Nov 15, 2011 at 11:04 PM, Roark  wrote:
> Hi,
>
> 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.

This looks like a job for SSH.

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


Re: Execute a command on remote machine in python

2011-11-15 Thread Jean-Michel Pichavant

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

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


Re: Execute a command on remote machine in python

2011-11-15 Thread Martin P. Hellwig

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
--
mph


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


Execute a command on remote machine in python

2011-11-15 Thread Roark
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.


Thanks in advance,
Roark.
-- 
http://mail.python.org/mailman/listinfo/python-list