title: Python Running OS command with quotes inside
body: <pre><code>#!/usr/bin/python
  import os
  
  readLine = open('desktops.txt','r')
  
  for line in readLine:
          machineName = line
          query = os.system('wmic -U corp.fakedomain.com/domainusername%password //192.168.1.100 "Select * from Win32_UserAccount Where LocalAccount = True"|grep "500|"|cut -d "\\" -f 2|cut -d "|" -f1')
  </code></pre>
  
  <p>I am receiving the following error...</p>
  
  <p>myhostname:~# ./getLocalAdminNames.py
  sh: Syntax error: Unterminated quoted string
  sh: Syntax error: Unterminated quoted string
  sh: Syntax error: Unterminated quoted string
  sh: Syntax error: Unterminated quoted string
  sh: Syntax error: Unterminated quoted string</p>
  
  <p>Then after I resolve the error I would like to substitute the IP with machineName variable.</p>
  
  <p>Any help would be greatly appreciated.</p>