【发布时间】:2019-09-12 10:52:07
【问题描述】:
我正在尝试使用 shell_exec 命令从 php 调用 python 文件。但是 shell_exec 没有给出任何输出。
我在终端上运行 python 脚本,它给了我正确的输出
python3 var/www/html/thilina/assets/documents/threadsearch.py keyword,equipment_types/2
这就是我在控制器中调用 python 脚本的方式
$key = $this->input->post('search');//from ajax
$fnum = $this->input->post('sub');//from ajax
$sym = $key.",".$fnum;//search key + 2
$chk = FCPATH."/assets/documents/threadsearch.py";
$chk = str_replace('\\', '/', $chk);
$output = shell_exec("python3 $chk $sym");//get the output from python script
【问题讨论】:
-
将执行权限授予
www-data。参考This answer
标签: php python python-3.x codeigniter ubuntu