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.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to