Php : read output from exec
<p>I'm launching a Python script from PHP and I'd like to get the line printed from that Python:</p>

<pre><code>exec( "python plotModule.py $myArray[0] $myArray[1]",  $output, $ret_code);
$fp = fopen('logDisp.txt', 'w');
fwrite($fp, "$output");
fclose($fp);
</code></pre>

<p>In Python I have a <code>print("hello")</code> in order to test if it's working. Nothing is written in logDisp.txt file.</p>

<p>Can you tell me why?</p>

<pre><code>exec( "python plotModule.py $myArray[0] $myArray[1]",  $output, $ret_code);
$fp = fopen('logDisp.txt', 'w');
fwrite($fp, json_encode($output));
fclose($fp);
</code></pre>

<p>Here you can see the jsonified response</p>

php python