title: How to run awk -F\' '{print $2}' inside subprocess.Popen in Python?
body: <p>I need to run a shell command inside subprocess.Popen in Python.</p>
  
  <p>The command is:
  $ virsh dumpxml server1 | grep 'source file' | awk -F\' '{print $2}'</p>
  
  <p>The output is:
  /vms/onion.qcow2</p>
  
  <p>I'm having two challenges with the above command:</p>
  
  <p>1) The command is inside a loop, and where you see 'server1', it is a variable that will have a server name.</p>
  
  <p>2) Python is complaining about KeyError: 'print $2'</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>proc = subprocess.Popen(["virsh dumpxml {0} | grep 'source file' | awk -F\' '{print $2}'".format(vm)], stdout=subprocess.PIPE, shell=True)
  
  stdout = proc.communicate()[0]
  </code></pre>
  
  <p>Thanks in advance.</p>