如何从PHP执行linux程序?
我想从php执行一个linux程序,我该怎么做 在linux终端中,我通常执行以下操作:如何从PHP执行linux程序?,php,linux,exec,Php,Linux,Exec,我想从php执行一个linux程序,我该怎么做 在linux终端中,我通常执行以下操作: ./program_name -o argument1 -f argument2 -out argument3 在PHP中如何实现这一点?您尝试过exec吗?壳牌执行董事?系统 您还应该了解如何转义特殊字符。 您还必须确保运行php/apache等的Linux用户具有运行系统命令所需的权限 检查功能 <?php $output = shell_exec('/path/to/program_na
./program_name -o argument1 -f argument2 -out argument3
在PHP中如何实现这一点?您尝试过exec吗?壳牌执行董事?系统 您还应该了解如何转义特殊字符。 您还必须确保运行php/apache等的Linux用户具有运行系统命令所需的权限 检查功能
<?php
$output = shell_exec('/path/to/program_name -o argument1 -f argument2 -out argument3');
echo $output;
?>
对我试过了,但似乎什么也没发生。我对如何传递参数感到困惑。php的工作目录不同于linux程序所在的目录,而是程序的完整路径。检查系统错误日志,看看有什么问题。为什么不能简单地执行“/path/to/program/-o argument1-f argument2-out argument3”;?