title: Sys Call Fails in Python
body: <p>I'm trying to allow custom monitoring by allowing custom system calls in a configuration file. It's a simple .ini file, but I'm having issues with the results I'm getting.</p>
  
  <pre><code>def sys_command(self, command):
  
      command_result = subprocess.check_output(["stat -c \"%s\" ./endpoint.py"], shell=True)
      return command_result
  </code></pre>
  
  <p>Above works fine.</p>
  
  <pre><code>def sys_command(self, command):
  
      command_result = subprocess.check_output([command], shell=True)
      return command_result
  </code></pre>
  
  <p>Above is what doesn't work when command is parsed from:</p>
  
  <pre><code>[directory]
  file_size = "stat -c \"%s\" {file}"
  </code></pre>
  
  <p>Other functions handle the parsing, mapping, and string replacement for {file}. I've checked the command being passed in and it is valid. Here is the error I am getting.</p>
  
  <pre><code>"stat -c \"%s\" ./endpoint.py"
  /bin/sh: stat -c "%s" ./endpoint.py: No such file or directory
  Traceback (most recent call last):
    File "monitor.py", line 147, in &lt;module&gt;
      print(test.custom_sys_command(test_focus_dict, "directory"))
    File "monitor.py", line 63, in custom_sys_command
      cmd_results = self.sys_command(parsed_cmd)
    File "monitor.py", line 70, in sys_command
      command_result = subprocess.check_output([command], shell=True)
    File "/usr/lib64/python2.7/subprocess.py", line 575, in check_output
      raise CalledProcessError(retcode, cmd, output=output)
  subprocess.CalledProcessError: Command '['"stat -c \\"%s\\" ./endpoint.py"']' returned non-zero exit status 127
  </code></pre>
  
  <p>The first line is the command that was parsed out and passed in. </p>
  
  <pre><code>subprocess.CalledProcessError: Command '['"stat -c "%s" ./endpoint.py"']' returned non-zero exit status 127
  </code></pre>
  
  <p>Above is the error I get if I remove the escape characters in the configuration file. </p>