I am attempting to write a php fping script and I am having trouble passsing the data to the executable. As you know fping pings in parallel making it very fast making it very desirable.

The following works the command prompt #

#fping -a < ip_table.txt

The text file contains multiple IP addresses separated by carriage returns.

What i am trying to do is the same thing in a php script.
So far i can get the following to work.

$host = "66.206.114.113";
$fping = exec("ping $host -ac1 -w2 | awk '/time/ {print $8}' | head -1 | awk -F '=' '{print $2}'");

However this does not...
<?
$myFile = "ip_hosts.txt";
$fh = fopen($myFile, 'r');
$host = fread($fh, filesize($myFile));
fclose($fh);

function do_ping($host, $fping, $p_result) {
echo $p_result . "<br>";
$fping = exec("ping $host -ac1 -w2 | awk '/time/ {print $8}' | head -1 | awk -F '=' '{print $2}'");

?>

So basiscally how do you take data from text file and pass it to an executable like fping?