The following bare-bones code will only ping a domain name local to the server the PHP code is stored on. I would like to be able to ping a series of external public IP addresses (eg. 66.235.203.72) which I cannot do with the following code:
This works:
Code: Select all
<?php
$ip_address = "www.thehostgroup.com";
exec("ping -c 1 $ip_address", $out, $var);
if ($var == 0)
{
print "Host is up";
}
else
{
print "Host is down";
}
?>Code: Select all
<?php
$ip_address = "66.235.203.72";
exec("ping -c 1 $ip_address", $out, $var);
if ($var == 0)
{
print "Host is up";
}
else
{
print "Host is down";
}
?>