Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Execute a command on remote machine in python
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Roark  
View profile  
 More options Nov 15 2011, 7:04 am
Newsgroups: comp.lang.python
From: Roark <suha...@gmail.com>
Date: Tue, 15 Nov 2011 04:04:51 -0800 (PST)
Local: Tues, Nov 15 2011 7:04 am
Subject: Execute a command on remote machine in python
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin P. Hellwig  
View profile  
 More options Nov 15 2011, 8:29 am
Newsgroups: comp.lang.python
From: "Martin P. Hellwig" <martin.hell...@gmail.com>
Date: Tue, 15 Nov 2011 13:29:23 +0000
Local: Tues, Nov 15 2011 8:29 am
Subject: Re: Execute a command on remote machine in python
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jean-Michel Pichavant  
View profile  
 More options Nov 15 2011, 9:03 am
Newsgroups: comp.lang.python
From: Jean-Michel Pichavant <jeanmic...@sequans.com>
Date: Tue, 15 Nov 2011 15:03:49 +0100
Local: Tues, Nov 15 2011 9:03 am
Subject: Re: Execute a command on remote machine in python

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Angelico  
View profile  
 More options Nov 15 2011, 9:10 am
Newsgroups: comp.lang.python
From: Chris Angelico <ros...@gmail.com>
Date: Wed, 16 Nov 2011 01:10:51 +1100
Local: Tues, Nov 15 2011 9:10 am
Subject: Re: Execute a command on remote machine in python

On Tue, Nov 15, 2011 at 11:04 PM, Roark <suha...@gmail.com> 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Nov 15 2011, 9:20 am
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Tue, 15 Nov 2011 09:20:50 -0500
Local: Tues, Nov 15 2011 9:20 am
Subject: Re: Execute a command on remote machine in python
In article <mailman.2728.1321366254.27778.python-l...@python.org>,
 Chris Angelico <ros...@gmail.com> wrote:

> On Tue, Nov 15, 2011 at 11:04 PM, Roark <suha...@gmail.com> 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Nawijn  
View profile  
 More options Nov 15 2011, 8:54 am
Newsgroups: comp.lang.python
From: Marco Nawijn <naw...@gmail.com>
Date: Tue, 15 Nov 2011 05:54:14 -0800 (PST)
Local: Tues, Nov 15 2011 8:54 am
Subject: Re: Execute a command on remote machine in python
On Nov 15, 1:04 pm, Roark <suha...@gmail.com> 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrick Brown  
View profile  
 More options Nov 15 2011, 10:57 am
Newsgroups: comp.lang.python
From: Rodrick Brown <rodrick.br...@gmail.com>
Date: Tue, 15 Nov 2011 10:57:16 -0500
Local: Tues, Nov 15 2011 10:57 am
Subject: Re: Execute a command on remote machine in python
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 <suha...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »