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


Groups > comp.lang.python > #29557

Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'arguments': 0.07; 'python': 0.09; 'arguments,': 0.09; 'received:mail- vc0-f174.google.com': 0.09; 'script,': 0.09; 'sep': 0.09; 'subject:script': 0.09; 'subject:using': 0.09; 'whitespaces': 0.09; 'worked,': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; '(the': 0.15; '12:50': 0.16; 'subject: \n ': 0.16; 'subject:ssh': 0.16; 'wed,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'module': 0.19; 'import': 0.21; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'pass': 0.25; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; '>>>>': 0.29; 'received:209.85.220.174': 0.29; 'url:python': 0.32; 'anybody': 0.32; 'running': 0.32; '(with': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'remote': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'subject: (': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'instead': 0.39; 'header:Received:5': 0.40; 'subject:, ': 0.61; 'containing': 0.61; 'subject: & ': 0.67; "'local'": 0.84; 'sender:addr:chris': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=E9XrAwYpIWulqxIcHrtc1FQU8Qf/wIfYdMnTgXjWKRk=; b=REpZEy95kno+sEVnN7xoNeFzudDbwOEFjuL/+yP0loQctYVDeCS9jpJopLFYcyebQi sT7wlNvbfsXhX9EGFJlt/XEmymKHLfcrLCKA5VP8DVa10/ywTrGZZMNLZoVbUHVFJibM wDsEu4nMqwV5N80vA7PUoqpdjuaxD9q5Molx4=
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=E9XrAwYpIWulqxIcHrtc1FQU8Qf/wIfYdMnTgXjWKRk=; b=WBRs1kdf80sbNc4Jfmr5ILvPINDvs3AffoN8x1uSVdx/KtsDKF8KYSODVAq4y4oawg pLlToQaHH1zcfCw2xzbwg8E5zuOU67j/P90Abs3Kw9JWELpK6jrIFEdthiEsjw7vY7VA iusArCVkmbP0713xGDGFZGMiPB82dRyuasUPIoHq1g4iwupb7lh8c0TTzu8qamiN4J6z upBZjkOgo5WUXdQzgqSxUHhRK0L5EW0F0CgNDcmE5Ncroxyr15dRoXYq2x/XTKsh+H6b NEM/hB9Hi0U0Pe3YSE9C5F3tId2RzlNBlrGT37cgZauoLjebLc/FqwUvh1f/GwJ44Pzo U1zQ==
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <10db83e4-80eb-4265-b11c-062269fea1b0@googlegroups.com>
References <10db83e4-80eb-4265-b11c-062269fea1b0@googlegroups.com>
Date Thu, 20 Sep 2012 09:19:12 -0700
X-Google-Sender-Auth q4mnpDKXJXJ7Dmg2SWkE0qUuKLg
Subject Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)
From Chris Rebert <clp2@rebertia.com>
To ashish <ashish.makani@gmail.com>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQlwf7EiWZ2Somu8vz1HMO5c6B6OlwA4npFIf2zxmd6TgZlF/op7gWl6aXEL3we9mL/2I08b
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.963.1348157960.27098.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348157960 news.xs4all.nl 6854 [2001:888:2000:d::a6]:43365
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29557

Show key headers only | View raw


On Wed, Sep 19, 2012 at 12:50 PM, ashish <ashish.makani@gmail.com> wrote:
<snip>
> 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).
<snip>
> 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.

Use the `subprocess` module instead (with shell=False). You then won't
need to worry about escaping.
http://docs.python.org/library/subprocess.html

Cheers,
Chris

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Passing arguments to & executing, a python script on a remote machine from a python script on local machine  (using ssh ?) ashish <ashish.makani@gmail.com> - 2012-09-19 12:50 -0700
  Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?) Ismael Farfán <sulfurfff@gmail.com> - 2012-09-19 15:29 -0500
    Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?) Piet van Oostrum <piet@vanoostrum.org> - 2012-09-20 19:30 +0200
  Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine  (using ssh ?) Tim Roberts <timr@probo.com> - 2012-09-19 20:51 -0700
  Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine  (using ssh ?) Emile van Sebille <emile@fenx.com> - 2012-09-20 07:50 -0700
  Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?) Chris Rebert <clp2@rebertia.com> - 2012-09-20 09:19 -0700
    Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?) Piet van Oostrum <piet@vanoostrum.org> - 2012-09-20 19:45 +0200

csiph-web