python & php - stdout redirect not working properly
<p>In my python script I redirect stdout to a file:</p>

<pre><code>sys.stdout = open("/home/pi/log.txt", "w")
print "test"
</code></pre>

<p>This works fine, but when I start the python script from a PHP the file is created correctly, but no lines are added to it. The log.txt simply stays empty!</p>

<pre><code>&lt;?php
exec('sudo -u pi python /home/pi/partyknipse/admin/upload.py')
?&gt;
</code></pre>

<p>Would appreciate any suggestion.</p>