Execute python in a php script using shell_exec()

前端 未结 6 999
自闭症患者
自闭症患者 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 21:56

    I think you need to refer to the full path for your python.

    for example use this instead:

    $output = shell_exec("/usr/bin/python full_path/my_script.py")
    

    instead of:

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

提交回复
热议问题