PING的PHP exec()函数不适用于Cpanel

标签 php centos exec cpanel ping

我创建了一个应用程序来监控 Network IPServer Status .它适用于 Windows xampp server并且还在 linux centos 6.0 上进行了测试.两者都工作得很好。但是当我将脚本上传到安装了 cpanel 的网站并且我的脚本在那里不起作用时。那是一个linux托管服务器

我的 Windows Ping 命令:

$exec = exec( "ping www.google.com -n 3 ". $output, $status );

我的 Centos ping 命令:
$exec = exec( "ping www.google.com -c 3 ". $output, $status );

两个$output$status变量返回准确的值。但是在 cpanel $output为空白且 $status变量返回 2 而不是 0 或 1

需要帮忙
谢谢,

最佳答案

如果是,请检查您的主机提供商是否允许使用此功能,所以
尝试像这样使用 exec:
$exec = exec( "ping www.google.com -c 3 ", $output, $status );
如果它不起作用,您可以尝试另一个 php 函数,如 exec:
system('ping www.google.com -c 3 ', $output);
您可以使用 nagios 进行监控,并在 nagios 之上构建您的应用程序

关于PING的PHP exec()函数不适用于Cpanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26558968/

相关文章:

javascript - 将表单值发送到多个页面

linux - 在 CentOS_7 1908 上使用 FMXLinux 时出现错误

c - 抓取 exec 的输出

php - Ajax Post 到 PHP 返回空数组

php - PHP更新后网站无法正确检索 session 信息

django - 错误 apache 配置错误 : couldn't perform authentication. AuthType 未设置!:/在 centos 6

java - 循环中的 Runtime.getRuntime().exec()

即使在 Windows 上后台运行命令后,PHP 脚本仍停留在 exec 上

PHP, .htaccess apache 统一 mod_rewrite 只用一个变量

centos - 几分钟后,IPTables 规则在 CentO 上自动刷新