5
I have a function that needs to drip 5 machines on the internal network. I am using the command below:
//EXECUTA O PING
exec("ping " . $host, $output, $result);
What happens is this. If I put any ip out of the standard, like "192.999.999.999" the function test, below, returns correctly that does not exist (OFF):
// TESTA O RESULTADO
if ($result == 0) {
echo "ON";
} else {
echo "OFF";
}
Now, if I put a correct ip, but that is only offline, it always returns me ON. If the ip is even online it also returns me ON, which is correct.
Is there any other way to use this ping in PHP? So that it recognizes when ip is offline?
Strange he return ON since technically the ping could only return an IP that was connected to the network, I will do some tests here and return with something soon.
– Vinicios Yals
When you "drip" on that computer offline, which is the value of the variable
result
? see:var_dump($result);
. Another thing, your OS is Windows?– stderr
Yes, it’s Windows. Actually already solved the problem, add the answer.
– Diego