php - 远程服务器上的 exec() 仅返回 return-var 1 |尝试了7种方法但没有成功

标签 php c apache .htaccess

在远程 apache 上(首先 PHP Version 5.3.29 | 最终更新到 7.04,没有启用安全模式),我尝试运行一个微小的 20 个字符的 c 文件“ccc”

 exec(), popen(), shell_exec(), system(), passthru(), backtick

...其中 6 种方法中有 5 种在本地取得了成功,到目前为止 6 种方法中有 0 种在远程取得了成功。

我在 6 种情况中的 3 种中得到返回值“1”( passthru, exec, system ),并且使用 popen 得到一个空(?)流(如果可能的话) (见下文)。

exec(), passthru(), system()愿意在远程服务器上运行像 ls 这样的命令,但是用 ccc 不给我任何东西,c-testfile 只包含 printf("c did"); ) 在里面。

升级到php-Version 7.04后服务器已配置(php-ini)没有安全模式。

我的文件 exec.php 仅尝试以 6 种方式运行 ccc(下面简称)

// start source

error_reporting(E_ALL); 

echo exec ('ls', $out0, $error0);

$popen = popen ($cpath.'ccc', 'r'); 
stream_get_contents ( $popen ); 

shell_exec ($cpath.'ccc');

passthru ($cpath.'ccc', $error3);

exec ($cpath.'ccc', $out4, $error4);

system ($cpath.'ccc', $error5);

$output = `$cpath.ccc`; 

echo '20160316 errors 0-6 | 0: '.$error0.' |  3: '.$error3.' | 4: '.$error4.' | 5: '.$error5.'<br/>';   
echo '20160316 outputs 0-6 | 0: '.gettype($out0).' | 1: '.get_resource_type($popen).' | 4: '.gettype($out4).';  

// end source

该文件确实在本地服务器上打开了 c 文件,没有错误, 但没有输出,并且在远程服务器上返回 1。

最佳答案

听起来 C 程序只是本地的。该程序必须位于远程服务器上。另外,apache 服务必须具有读取和执行权限。

关于php - 远程服务器上的 exec() 仅返回 return-var 1 |尝试了7种方法但没有成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36038272/

相关文章:

javascript - 取消混合 php 和 js 文件

php - 如何每天自动运行php脚本?

c - Lua C API : Initializing a variable matrix in a structure C

apache - 从 apache 服务中排除 404

Apache - 如何将 http 请求仅转换为 https?

PHP,无法回复电子邮件

c - 使用系统调用打印结果

c++ - statvfs 可以阻止某些网络设备吗?这种情况怎么处理?

java - 如何在我的 Apache 网络服务器上托管 jar 文件?

PHP Lumen 在 null 上调用成员函数 connection()