【发布时间】:2018-10-23 13:27:02
【问题描述】:
我创建了一个php文件,如下所示。
<?php
$ar = 4600;
$az = "redshift -O ".$ar;
echo "Command executed: ";
echo $az;
system($az,$status); // It is not working on browser but working on terminal.
system("ls",$asd); // It is working on both browser and terminal.
if($status == NULL) {
echo "<h3>Operation not successful</h3>";
}
else
echo "<h3>Temperature Succesfully set to ".$ar."</h3>";
?>
问题是这样的
当我使用命令在终端上运行此文件时
php file.php
“ls”命令正在执行,“redshift -O 4600”也正在执行。
但是当我使用 url 在浏览器上执行这个文件时。
127.0.0.1/file.php
只有“ls”命令被执行。 'redshift -O 4600' 没有被执行。有什么方法可以让我执行这样的程序。 我也尝试过其他功能,如 exec 等。
【问题讨论】:
-
redshift的完整路径?权限问题? -
我将路径更改为 /usr/bin/redshift 但仍然没有执行
-
从终端运行脚本的用户和运行apache的用户一样吗?
-
@xatzistnr 可能是正确的。
var_dump($status)的输出是什么,它应该包含一个返回代码来说明问题? -
var_dump($status) 的输出是 (int)1。
标签: php apache web-services server