title: Output of command to list using Python
body: <p>I'm writing an automation script, where it needs to run a command and the output of command should be captured as a list.</p>
  
  <p>For example:</p>
  
  <pre>
  # ls -l | awk '{print $9}'
  test1
  test2
  </pre>
  
  <p>I want the output to be captured as a list like <code>var = ["test1", "test2"]</code>.</p>
  
  <p>Right now I tried  this but it is saving as string instead of list:</p>
  
  <pre>
  # Filter the tungsten services
  s = subprocess.Popen(["ls -l | awk '{print $9}'"], shell=True, stdout=subprocess.PIPE).stdout
  service_state = s.read()
  </pre>
  
  <p>Please guide me if anyone has any idea to achieve this.</p>