title: Running a python file from php does not generate the output file
body: <p>I have a problem running another file from php. I want my php params to be the output of running a python file that calls another file itself.</p>
  
  <p>Here is my php file:</p>
  
  <pre><code>&lt;?php
      if (isset($_POST['submit'])) {
      $params = solve();
  }
  
  function solve() {
    exec("python array.py", $output);
    return $output;
  }
  ?&gt;
  </code></pre>
  
  <p>If array.py is simply:</p>
  
  <pre><code>if __name__ == "__main__":
      print 1
      print 2
      print 3
      print 4
  </code></pre>
  
  <p>I will get 1,2,3,4 for my output, but I as soon as I change array.py to the following file that calls os.system, I don't get anything. So the new array.py is:</p>
  
  <pre><code>import os
  
  def main():
      os.system("python test.py") #test.py creates tmp.txt with 4 lines w/ values 1,2,3,4
  
  
  def output():
      f = open("tmp.txt", "r")
      myReturn = []
      currentline = f.readline()
  
      while currentline:
            val = currentline[:-1]  #Getting rid of '\n'
            val = int(val)
            myReturn = myReturn + [val]
            currentline = f.readline()
      f.close()
      return myReturn
  
  
  if __name__ == "__main__":
       main()
       o = output()
       print o[0]
       print o[1]
       print o[2]
       print o[3]
  </code></pre>
  
  <p>Also if I just run test.py, the output is the file tmp.txt:</p>
  
  <pre><code> 1
   2
   3
   4
  </code></pre>
  
  <p>So now, when I run my php file, the output tmp.txt is not even created in the directory and as a result I don't get any output from my php either.
  I am not sure why this is happening because when I just run array.py myself, I get the desired output, and the tmp file is created.</p>
  
  <p>EDIT:
  I forgot to include: import os above.</p>