Getting PHP to run a Python script

前端 未结 4 951
时光取名叫无心
时光取名叫无心 2020-12-06 05:24

I am trying to run a Python program using PHP. Here\'s the code

$command = \'/usr/local/bin/python script.py file\';
$temp = exec($command, $output);
         


        
4条回答
  •  天涯浪人
    2020-12-06 06:07

    To get my CodeIgniter helper to run a python script, I had to put #!/usr/bin/python on the first line of my python script, and NOT call python from the exec.

    +1 for also doing chmod +x

    My helper looks like this:

    
    

提交回复
热议问题