Execute python in a php script using shell_exec()

前端 未结 6 1036
自闭症患者
自闭症患者 2021-01-02 21:45

I\'m experiencing a weird problem in trying to execute python in a php server (LAMP). (safe_mode off)

if I type:

$output = shell_exec(\"ls -lah\");
e         


        
6条回答
  •  星月不相逢
    2021-01-02 22:09

    If you are trying to run the python script using the following code

    $output = shell_exec("python my_script.py");
    

    you will need to use absolute path for my_script.py and give all permissions (I am not sure which ones are sufficient) for the python file.

提交回复
热议问题