Reputation: 117
I have created an application to monitor Network IP
or Server Status
. It is working fine for windows xampp server
and also tested on linux centos 6.0
. Both are working good. But When i uploaded the script to a website where cpanel is installed and my script is not working there. That is a linux hosting server
My Ping Command for Windows:
$exec = exec( "ping www.google.com -n 3 ". $output, $status );
My Ping Command for Centos:
$exec = exec( "ping www.google.com -c 3 ". $output, $status );
both $output
and $status
variable is returning accurate values. But in cpanel $output
is blank and $status
variable is returning 2 instead of 0 or 1
Need Help Thanks,
Upvotes: 0
Views: 2450
Reputation: 589
Check first, exec function is disabled by your Hosting Provider or not by using the given function. This function will list out all the disabled functions by your hosting provider.
function disabled_functions(){
$disabled = explode(',', ini_get('disable_functions'));
return $disabled;
}
echo '<pre>';
print_r(disabled_functions());
If exec exists in the output of the above disabled_functions(), then you have to consult your hosting provider to allow shell access and exec. Generally hosting providers disable shell access and functions similar to exec because of security issues.
Upvotes: 0
Reputation: 826
check if your host provider is allowing the use this function if yes , so
try using the exec like this:
$exec = exec( "ping www.google.com -c 3 ", $output, $status );
if its not working you can try another php function like exec:
system('ping www.google.com -c 3 ', $output);
you can use nagios for monitoring and build your application on top of nagios
Upvotes: 1