Execute python in a php script using shell_exec()

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

    What does

    which python
    

    tell you, both from the command line and from shell_exec()? It should tell you which (if any) Python interpreter it's finding (from $PATH). Don't forget that it's quite possible that the $PATH used from the Linux command line might not be the same as the $PATH used by shell_exec()! Once you find the Python interpreter you want to use, you might have to hard code it in the shell_exec().

提交回复
热议问题