title: How can i run "exec" function in php for running a python file in a server, can i use a url or only a filesystem path?
body: <p>I wrote a short python script and i use "exec" in php for running that script. The python and php files are uploaded in a university server with apache webserver that is installed on windows. I installed on windows (at the university server) the python exe file python2.7.</p>
  
  <p>Php does not receive data with exec:</p>
  
  <pre><code> array(0) { } Array ( ) after output
  </code></pre>
  
  <p>I tried system() function: </p>
  
  <pre><code>before exec vardump int(2) mystring string(0) "" printr output 2
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>     echo "before exec";
           $command = "C:\\Python27\\python.exe C:\\path\\py\\prova.py"; 
       $command .= " $param1 2&gt;&amp;1";
      $mystring = system($command, $output);
      print(" vardump ");
      var_dump($output);
      print(" mystring ");
      var_dump($mystring);
      print(" printr output ");
      print_r($output);
  </code></pre>
  
  <p>python code:</p>
  
  <pre><code>#PATHMAIN
  if len(sys.argv) &gt; 1:
      sys.argv[1].replace("\\\\", "\\")
      path1img = sys.argv[1]
  else:
      path1img = "http://site/folder/Images/Highres/d (0).jpg" 
  
  
  def comparison(path1img):
  
      import numpy as np
      from numpy import array
      import cv2
      import predict as pr
      #import bp1img
      import moduloSkeleton
  
      listafeaturevector = list()
      featurev = list()
      sep = list()
      sbp = list()
      sangle = list()
      a = 111111111111111111111111111111
      print("hello")
      return a
  </code></pre>
  
  <p>I tried also</p>
  
  <pre><code>$command = "python \site\py\prova.py";
  
  $command = "python http://site\\folder\\py\\prova.py";
  
  $command = "C:Python27\\python http://site\\folder\\py\\prova.py";
  
  $command = "C:Python27\\ \\folder\\py\\prova.py"
  
  $command = "python27 \\folder\\py\\prova.py"
  
  $command = "python27 http://site\\folder\\py\\prova.py"
  
  $command = "C:\\python27\\python C:\\path\\py\\prova.py"
  </code></pre>