Getting PHP to run a Python script

前端 未结 4 937
时光取名叫无心
时光取名叫无心 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:31

    Realized what was wrong:

    1. The domain was set up as a virtual host and PHP's safe_mode was enabled. proc_open, exec, system, passthru etc. do not work under safe_mode I guess.

    2. Put the script in the directory accessible by the vhost. Apache wasn't able to access the directories outside the vhost document root.

    Thanks for the help!

提交回复
热议问题