Execute python script with output from php
<p>Is there any special permission or setting in order to execute a python script that create a new file or image? 
This is my code:</p>

<pre><code>&lt;?
function py(){
    exec( 'python my_script.py');
    echo "ok";
}

py();
?&gt;
</code></pre>

<p>And this is my python script (an example):</p>

<pre><code>#!/usr/bin/python
import sys

f = open('out.txt', 'w')
print &gt;&gt; f, 'thats all'
f.close()
</code></pre>

<p>Running php i get "ok" message but no file is created. What am i doing wrong?</p>

<p>You need to call <code>shell_exec()</code> not <code>exec()</code> if you want to be able to capture the output:</p>

<p><a href="http://php.net/manual/en/ref.exec.php" rel="nofollow">Refernce: PHP Manual</a></p>

php python