Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!ecngs!feeder2.ecngs.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'one?': 0.05; 'escape': 0.07; 'python': 0.10; 'commandline': 0.16; 'googled': 0.16; 'subprocess': 0.16; 'wrote:': 0.16; 'shell': 0.18; '2015': 0.20; 'to:name:python-list@python.org': 0.20; 'fine,': 0.22; 'sep': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'script': 0.25; 'appear': 0.26; 'external': 0.27; 'parameters': 0.27; 'message- id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'another': 0.32; 'quotes': 0.33; "skip:' 20": 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'skip:p 20': 0.38; 'to:addr:python.org': 0.40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=f3WShWR0oqfe3co7vaBR2P2dnklEZ+Lhu54KMP8KTiA=; b=N6Riahq7CQzRmZYqReqQmOxKWbpv1plh+Ssn+Z7aEfaNDjd0OoZyVwUjWQND052/Nl MxhrClXBLOqMJAciS7oNpKZhh50GqLqeFvKj3zkIeNC6fU+v+LYIahU0VEQ+aWSUylIA 69HZwqZHB7Oo2JSy/xN9zDvMaX0MSWGTHMwLLbxkFHwGknivuDq+PFeHrIf0AjsBKNSf M1+labTqVc3wkSFV7dS8Osb8nP+9FaV2HoBwnVCxVtKdwYHUzJTZPGVfFVSH56woZSmn cxbj1fKM7z6w5Oz3JGpF4qj0vU2w7Kr3GYV3iArjy1J832AC/yQK52+NYBDPOaBxlFQr TIdg== MIME-Version: 1.0 X-Received: by 10.107.18.231 with SMTP id 100mr39012151ios.15.1441710672704; Tue, 08 Sep 2015 04:11:12 -0700 (PDT) In-Reply-To: <1e6570d1-42be-432d-a690-43c4e417ec00@googlegroups.com> References: <1e6570d1-42be-432d-a690-43c4e417ec00@googlegroups.com> Date: Tue, 8 Sep 2015 07:11:12 -0400 Subject: Re: passing double quotes in subprocess From: Larry Martell To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441710675 news.xs4all.nl 23744 [2001:888:2000:d::a6]:57837 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96117 On Tue, Sep 8, 2015 at 7:03 AM, loial wrote: > I need to execute an external shell script via subprocess on Linux. > > One of the parameters needs to be passed inside double quotes > > But the double quotes do not appear to be passed to the script > > I am using : > > myscript = '/home/john/myscript' > commandline = myscript + ' ' + '\"Hello\"' > > process = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) > output,err = process.communicate() > > > if I make the call from another shell script and escape the double quotes it works fine, but not when I use python and subprocess. > > I have googled this but cannot find a solution...is there one? Try it with 2 backslashes: commandline = myscript + ' ' + '\\"Hello\\"'