title: Running a Python script from PHP
body: <p>I'm trying to run a Python script from PHP using the following command:</p>
  
  <p><code>exec('/usr/bin/python2.7 /srv/http/assets/py/switch.py arg1 arg2');</code></p>
  
  <p>However, PHP simply doesn't produce any output. Error reporting is set to E_ALL and display_errors is on.</p>
  
  <p>Here's what I've tried:</p>
  
  <ul>
  <li>I used <code>python2</code>, <code>/usr/bin/python2</code> and <code>python2.7</code> instead of <code>/usr/bin/python2.7</code></li>
  <li>I also used a relative path instead of an absolute path which didn't change anything either.</li>
  <li>I tried using the commands <code>exec</code>, <code>shell_exec</code>, <code>system</code>.</li>
  </ul>
  
  <p>However, if I run</p>
  
  <pre><code>if (exec('echo TEST') == 'TEST')
  {
      echo 'exec works!';
  }
  </code></pre>
  
  <p>it works perfectly fine while <code>shutdown now</code> doesn't do anything.</p>
  
  <p>PHP has the permissions to access and execute the file.</p>
  
  <p>EDIT: Thanks to Alejandro, I was able to fix the problem. If you have the same problem, don't forget that your webserver probably/hopefully doesn't run as root. <strong>Try logging in as your webserver's user or a user with similar permissions and try to run the commands yourself.</strong></p>