Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29523 > unrolled thread

Passing arguments to & executing, a python script on a remote machine from a python script on local machine

Started byashish <ashish.makani@gmail.com>
First post2012-09-19 12:46 -0700
Last post2012-09-20 00:28 -0700
Articles 5 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Passing arguments to & executing, a python script on a remote machine from a python script on local machine ashish <ashish.makani@gmail.com> - 2012-09-19 12:46 -0700
    Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-20 04:27 +0000
      Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine Chris Angelico <rosuav@gmail.com> - 2012-09-20 15:09 +1000
        Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine ashish <ashish.makani@gmail.com> - 2012-09-20 00:28 -0700
        Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine ashish <ashish.makani@gmail.com> - 2012-09-20 00:28 -0700

#29523 — Passing arguments to & executing, a python script on a remote machine from a python script on local machine

Fromashish <ashish.makani@gmail.com>
Date2012-09-19 12:46 -0700
SubjectPassing arguments to & executing, a python script on a remote machine from a python script on local machine
Message-ID<5a8a09f8-db4c-4f1d-ae8e-a5c848903c68@googlegroups.com>
Hi PyTutor Folks

Here is my situation

1. I have two machines. Lets call them local & remote.
Both run ubuntu & both have python installed

2. I have a python script, local.py, running on local which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to a python script, remote.py running on remote (the remote machine).

I have the following questions:

1. What's the best way to accomplish my task ?
I have researched quite a bit & so far found really conflicting & complex workarounds. 

I googled & found people using several libraries to accomplish ssh to remote machine & execute a command on remote machine.
paramiko ( now forked into the ssh moduke), fabric, pushy ,etc

People who have used any of these libraries, which one would you recommend, as the most apt (simple & easy to use, lightweight, best performance, etc) for my situation ?

2. I would prefer a solution, which does NOT require the installation of extra libraries on the local & remote machines.
If installing external librar

3. Has anybody been able to do this using os.system ?

I tried this
>>> import os
>>> os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3")

This worked, but if the arguments i tried to pass, had spaces, i was not able to 'escape' the spaces.

Any & all explanations/links/code snippets/thoughts/ideas/suggestions/feedback/comments/ of the Python tutor community would be greatly appreciated.

Thanks a ton

cheers
ashish

email : 
ashish.makani
domain:gmail.com

“The only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it.” - Steve Jobs (1955 - 2011)

[toc] | [next] | [standalone]


#29539

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-09-20 04:27 +0000
Message-ID<505a9b22$0$29890$c3e8da3$5496439d@news.astraweb.com>
In reply to#29523
On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:

> Hi PyTutor Folks
> 
> Here is my situation
> 
> 1. I have two machines. Lets call them local & remote. Both run ubuntu &
> both have python installed
> 
> 2. I have a python script, local.py, running on local which needs to
> pass arguments ( 3/4 string arguments, containing whitespaces like
> spaces, etc ) to a python script, remote.py running on remote (the
> remote machine).

If 3/4 of the arguments are strings, what sort of objects are the other 
1/4?


> I have the following questions:
> 
> 1. What's the best way to accomplish my task ? 

Use a dedicated remote procedure call library. Do not try to invent your 
own. The wheel has already been invented, you are just wasting your time.

I've used both Pyro and Rpyc, either of them seem perfectly reasonable. 
There are many others, but frankly I don't think there is a "best of 
breed" that stands far ahead of the rest.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#29540

FromChris Angelico <rosuav@gmail.com>
Date2012-09-20 15:09 +1000
Message-ID<mailman.951.1348117767.27098.python-list@python.org>
In reply to#29539
On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
>
>> 2. I have a python script, local.py, running on local which needs to
>> pass arguments ( 3/4 string arguments, containing whitespaces like
>> spaces, etc ) to a python script, remote.py running on remote (the
>> remote machine).
>
> If 3/4 of the arguments are strings, what sort of objects are the other
> 1/4?

I understand the OP as meaning "three or four string arguments".

ChrisA

[toc] | [prev] | [next] | [standalone]


#29543

Fromashish <ashish.makani@gmail.com>
Date2012-09-20 00:28 -0700
Message-ID<6f04ab26-8e8e-4531-85a9-622bc9603686@googlegroups.com>
In reply to#29540
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
> 
> <steve+comp.lang.python@pearwood.info> wrote:
> 
> > On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
> 
> >
> 
> >> 2. I have a python script, local.py, running on local which needs to
> 
> >> pass arguments ( 3/4 string arguments, containing whitespaces like
> 
> >> spaces, etc ) to a python script, remote.py running on remote (the
> 
> >> remote machine).
> 
> >
> 
> > If 3/4 of the arguments are strings, what sort of objects are the other
> 
> > 1/4?

Sorry for the confusion Steven.
There are 3 or 4 arguments, all of which are strings.

> 
> 
> 
> I understand the OP as meaning "three or four string arguments".

Yup, that's what i meant.
> 
> 
> 
> ChrisA

[toc] | [prev] | [next] | [standalone]


#29544

Fromashish <ashish.makani@gmail.com>
Date2012-09-20 00:28 -0700
Message-ID<mailman.953.1348126115.27098.python-list@python.org>
In reply to#29540
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
> 
> <steve+comp.lang.python@pearwood.info> wrote:
> 
> > On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
> 
> >
> 
> >> 2. I have a python script, local.py, running on local which needs to
> 
> >> pass arguments ( 3/4 string arguments, containing whitespaces like
> 
> >> spaces, etc ) to a python script, remote.py running on remote (the
> 
> >> remote machine).
> 
> >
> 
> > If 3/4 of the arguments are strings, what sort of objects are the other
> 
> > 1/4?

Sorry for the confusion Steven.
There are 3 or 4 arguments, all of which are strings.

> 
> 
> 
> I understand the OP as meaning "three or four string arguments".

Yup, that's what i meant.
> 
> 
> 
> ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web