Execute python in a php script using shell_exec()

前端 未结 6 1020
自闭症患者
自闭症患者 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:11

    I think this may help...

    looks like the output for the python call needs to be routed properly. I was able to make this work within my index.php file for returning the python version...

    shell_exec("python -V 2>&1");
    

    Here is where I found the answer.

提交回复
热议问题