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

Newsgroups comp.lang.python
Date 2012-07-21 09:03 -0700
References <CAK4NeTGkCfpMp09hw0-WUjY8t3QUBku=UrMjpXLcmKXwq6HvbA@mail.gmail.com> <mailman.2380.1342873263.4697.python-list@python.org>
Subject Re: Calling Java jar class with parameter from Python
From jasonveldicott@gmail.com
Message-ID <mailman.2386.1342886640.4697.python-list@python.org> (permalink)

Show all headers | 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