title: Python Running subprocess with arguments in double quotes AND in a subdirectory with spaces
body: <p>I want to run an executable program which resides in a directory <em>below</em> my script path. The path contains spaces <em>and</em> one the program arguments requires double quotes.</p>
  
  <p>This seems to be a composite of other questions already asked here (<a href="https://stackoverflow.com/questions/11846232/handling-directories-with-spaces-python-subprocess-call">Handling directories with spaces Python subprocess.call()</a>, <a href="https://stackoverflow.com/questions/14928860/passing-double-quote-shell-commands-in-python-to-subprocess-popen">Passing double quote shell commands in python to subprocess.Popen()?</a>) but none of them provided a proper solution for my problem.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import subprocess
  
  subdir = 'ogr\\'
  command = subdir + 'ogr2ogr.exe -f "ESRI Shapefile" output0.shp input0.kml'
  
  output,error = subprocess.Popen(
      command, universal_newlines=True, shell=True, 
      stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
  </code></pre>
  
  <p>The executable which I am trying to run (ogr2ogr.exe) resides o
  in a "ogr\" subdirectory below my script, which in turn is in a directory containing spaces (eg., C:\My Documents\My Apps\Scripts\myscript.py). One of its parameters require double quotes. The above commands handle the double quotes in the arguments and work well if I put the script and the input file (input0.kml) in the same subdirectory of the executable, but fail with the message "The system cannot find the specified file" if I attempt to run it in the same directory of the script itself. </p>
  
  <p>Any hints?</p>
  
  <p>Thanks in advance!</p>