shell_exec、popen、exec、passthrough在codeigniter控制器中不工作


shell_exec, popen, exec, passthru not working in codeigniter controller

我有一个要求,我需要从codeigniter控制器运行一个c程序,phpshell命令在控制器中不起作用,但当从一个简单的php(没有codeigniter)使用相同的命令时,它工作得很好。

  • 我已经检查了php.ini设置,shell_exec、exec和popen都已启用

请帮忙。。。

iam使用的命令是

$output = shell_exec("./hello"); //hello.c prints hello world.
echo $output;

使用pwd打印的路径是C文件所在的主文件夹路径。相同的命令(shell_exec("./hello");)在codeigniter中不起作用。

请检查您是否为代码点火器中的exec命令提供了正确的路径。使用以下内容检查当前目录。

exec('pwd');

此外,如果它在不正确的目录中,请执行提供完整的路径。

检查c代码文件是否在此目录中。如果没有,则相应地进行更改。

请在您的问题中也提供exec命令。

您应该在exec命令中提供绝对路径。

$output = shell_exec("/absolute/path/to/executable/hello"); //hello.c prints hello world.
echo $output;