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


Groups > comp.lang.python > #25746

Re: Calling Java jar class with parameter from Python

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 <jasonveldicott@gmail.com>
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; '&gt;': 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 <mailman.2380.1342873263.4697.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=14.200.68.34; posting-account=W1njawoAAABEc6blRhWAGfh1f9pI6GBx
References <CAK4NeTGkCfpMp09hw0-WUjY8t3QUBku=UrMjpXLcmKXwq6HvbA@mail.gmail.com> <mailman.2380.1342873263.4697.python-list@python.org>
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 <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>
Message-ID <mailman.2386.1342886640.4697.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Saturday, July 21, 2012 5:20:48 AM UTC-7, Peter Otten wrote:
> Jason Veldicott wrote:
> 
> &gt; subprocess.Popen([&quot;C:\\Program Files
> &gt; (x86)\\Java\\jdk1.7.0_05\\bin\\java.exe&quot;, &quot;-cp
> &gt; c:\\antlr\\antlr-3.4-complete.jar org.antlr.Tool&quot;,
> &gt; &quot;C:\\Users\\Jason\\Documents\\antlr\\java grammar\\Java.g&quot;],
> &gt; stdout=subprocess.PIPE, shell=True ).communicate()
> &gt; 
> &gt; 
> &gt; Obviously, some trick is being missed.  Could anyone shed light on what it
> &gt; 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([
>   &quot;C:\\Program Files (x86)\\Java\\jdk1.7.0_05\\bin\\java.exe&quot;,
>   &quot;-cp&quot;,
>   &quot;C:\\antlr\\antlr-3.4-complete.jar&quot;,
>   &quot;org.antlr.Tool&quot;,
>   &quot;C:\\Users\\Jason\\Documents\\antlr\\java grammar\\Java.g&quot;],
>    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.

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


Thread

Re: Calling Java jar class with parameter from Python Peter Otten <__peter__@web.de> - 2012-07-21 14:20 +0200
  Re: Calling Java jar class with parameter from Python Roy Smith <roy@panix.com> - 2012-07-21 09:57 -0400
    Re: Calling Java jar class with parameter from Python jasonveldicott@gmail.com - 2012-07-21 09:11 -0700
  Re: Calling Java jar class with parameter from Python jasonveldicott@gmail.com - 2012-07-21 09:03 -0700
  Re: Calling Java jar class with parameter from Python jasonveldicott@gmail.com - 2012-07-21 09:03 -0700

csiph-web