Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; '21,': 0.07; 'arguments': 0.07; 'nested': 0.07; 'separating': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'arbitrarily': 0.16; 'obviously,': 0.16; 'subject:Java': 0.16; 'subject:class': 0.16; 'subprocess': 0.16; 'wrote:': 0.17; 'obviously': 0.18; 'thanks.': 0.21; 'cc:2**0': 0.23; '>': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'post': 0.28; 'spaces': 0.29; 'case,': 0.29; 'skip:& 10': 0.29; 'skip:( 40': 0.30; 'file': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'impression': 0.33; 'anyone': 0.33; 'another': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'needed': 0.35; 'jason': 0.35; 'received:209.85': 0.35; 'subject:with': 0.36; 'should': 0.36; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'think': 0.40; 'july': 0.60; 'from:no real name:2**0': 0.60; "you've": 0.61; 'otten': 0.84; 'thoroughly': 0.84; 'trick,': 0.84; 'received:209.85.213.184': 0.91; 'received:mail-yx0-f184.google.com': 0.91 Newsgroups: comp.lang.python Date: Sat, 21 Jul 2012 09:03:57 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=14.200.68.34; posting-account=W1njawoAAABEc6blRhWAGfh1f9pI6GBx References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 14.200.68.34 MIME-Version: 1.0 Subject: Re: Calling Java jar class with parameter from Python From: jasonveldicott@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342886640 news.xs4all.nl 6901 [2001:888:2000:d::a6]:53691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25746 On Saturday, July 21, 2012 5:20:48 AM UTC-7, Peter Otten wrote: > Jason Veldicott wrote: > > > subprocess.Popen(["C:\\Program Files > > (x86)\\Java\\jdk1.7.0_05\\bin\\java.exe", "-cp > > c:\\antlr\\antlr-3.4-complete.jar org.antlr.Tool", > > "C:\\Users\\Jason\\Documents\\antlr\\java grammar\\Java.g"], > > stdout=subprocess.PIPE, shell=True ).communicate() > > > > > > Obviously, some trick is being missed. Could anyone shed light on what it > > may be? > > File names with spaces can be tricky. Try thoroughly separating the > individual arguments and let subprocess do the necessary escaping. > I think it should be > > subprocess.Popen([ > "C:\\Program Files (x86)\\Java\\jdk1.7.0_05\\bin\\java.exe", > "-cp", > "C:\\antlr\\antlr-3.4-complete.jar", > "org.antlr.Tool", > "C:\\Users\\Jason\\Documents\\antlr\\java grammar\\Java.g"], > stdout=subprocess.PIPE).communicate() That did the trick, thanks. I had the impression from another post that the breaking up of command strings into subprocess arguments could be done arbitrarily as needed to deal with nested inverted commas. Obviously as you've shown, this is not the case, at least for Popen.