I have an application to develop for the university. Something simple. But I'm inexperienced on how to do it. It's exactly what I want to do; If I send ping 50 IP addresses at 3 minute intervals, I would like the IP address to write on the admin panel off if it is turned off and open if it is turned on. (red and green button maybe ) How ı can do it exactly? Since the servers belong to us, I want the commands to work correctly. What exactly do I want to show on the screen if Ping is successful?
Asked
Active
Viewed 736 times
-2
-
Is your php-server allowed to do shell-execution? http://php.net/manual/de/function.shell-exec.php – nologin Feb 08 '19 at 17:15
-
@nologin server its our univercity so yes. I can give php permission. – Vedat Kurtay Feb 08 '19 at 17:16
1 Answers
0
You can quickly use the hostsystems ping-command by using shell-execution, if available. So you don't have to implement your own php-ping-service as described in the other solution. This can be done if easier solutions don't work. In my opinion less code is always better.
<?php
$output = shell_exec('ping www.stackoverflow.com');
echo "<pre>$output</pre>";
?>

nologin
- 1,402
- 8
- 15
-
But ı have a 50 IP adress ? Is this what I need to do one by one for each process? – Vedat Kurtay Feb 08 '19 at 17:17
-
-
@user3647971 What do you suggest? I don't know much about this. Our IP adress not public. – Vedat Kurtay Feb 08 '19 at 17:19
-
This question already has an answer here: https://stackoverflow.com/questions/8030789/pinging-an-ip-address-using-php-and-echoing-the-result @Judge Medya – user3647971 Feb 08 '19 at 17:20
-
Yes, the other answers are more php-like, but mine has the shortest code so you can make less errors ;) – nologin Feb 08 '19 at 17:23
-
-
Have a look at e.g. https://linux.die.net/man/8/ping how to setup "your" ping command (without re-implementing it) – nologin Feb 08 '19 at 17:40
-
Could you add any commentary to your answer? Explain your logic, and give a little commentary on what your code is intended to do. This will help the OP, but it will also serve as commentary for future users – Nimitt Shah Feb 08 '19 at 20:20