title: Running python script from php and write to a file
body: <p>My php code is in htdocs/series/index.php.
  My python code location is /home/shivam/Desktop/hello.py
  I am running php using xampp in ubuntu.
  here is php code</p>
  
  <pre><code> &lt;?php
  $command = escapeshellcmd('/home/shivam/Desktop/hello.py');
  $output = shell_exec($command);
  echo $output;
  ?&gt;
  </code></pre>
  
  <p>here is my python code</p>
  
  <pre><code>#!/usr/bin/env python
  with open("/home/shivam/Desktop/solution.txt", "w") as myfile:
      myfile.write("write text")
  </code></pre>
  
  <p>I am trying to run the python script using php to write to a file 'solution.txt'. When i write something myself to solution.txt and open it in read mode using python script via php then it works but when i try to write using above code ,i am unable to do so. 
  One more thing, none of the code below the line "with open("/home/shivam/Desktop/solution.txt", "w") as myfile:" gets executed.
  I have tried the solution given in : <a href="https://stackoverflow.com/questions/32547008/php-call-python-script-and-the-python-script-cannot-write-to-a-file">enter link description here</a></p>