Using the System() function to run a ping
Posted: Thu Oct 26, 2006 7:10 am
I stumbled across a script that lets you input a host to ping and it shows the results on the screen. This particular script returns each ping when it has results for it though, so a ping count of 10 will return each ping as it is detected.
I tried to write my own script to do exactly the same, but mine only returns the data once it has completed the process. So if I run a count of 10 pings then the webpage hangs untill the process is complete.
Could someone point out what I need to do for the script to return each ping result when it's returned in the shell. I'm running on a Linux box you may want to know.
Here is my code:
Regards,
I tried to write my own script to do exactly the same, but mine only returns the data once it has completed the process. So if I run a count of 10 pings then the webpage hangs untill the process is complete.
Could someone point out what I need to do for the script to return each ping result when it's returned in the shell. I'm running on a Linux box you may want to know.
Here is my code:
Code: Select all
$host = $_POST["host"];
$count = $_POST["count"];
system("ping $host -c $count");Regards,