OBJECTIVE: The below is the script that I am trying to use for getting each IP's UP status. If the IP is Up it will each 13.61.28.20 - yes
else 13.61.28.20 - no
.
PROBLEM: I am not getting any result with the below script. To find this to be executed as this is working very good for single ip without a foreach
loop.
PERFORMANCE: If I try the same for multiple IPs inside a foreach loop this is causing a problem by keep spinning and never returns a result.
<?php
$allIps = range(0,254);
foreach($allIps as $subNetIp){
$subNetIp = (string)$subNetIp;
$urlHeader = "13.61.29.".$subNetIp;
$checkUrl = "curl -k ".$urlHeader;
$status = exec($checkUrl, $result, $retVal);
echo $status ? $urlHeader.' - yes' : $urlHeader.' - no';
echo '<br>';
}
?>
Can anyone help me refactoring this code and make this work as expected.
EXPECTED BEHAVIOUR: Script's performance should be very one like once after it's pings and IP it should print on the browser and not keep loading. Finally it should finish all the IP in the give range
which is $allIps = range(0,254);
.