About ping command

Hi!

I have small problem. I want to ping a server and the result shouldn't be printed in the browser window, just become a value.

Here you can see the script that I have:

$command="ping linux.com -t ttl -c1 | tail -1 | awk '{print $4 \" \" $5}'";
$output = system($command);
system("exit(0)");
echo "DATA: $output";
?>

When I run this in my browser the resualt will be as follow:

33.1/33.1/33.1 ms DATA: 33.1/33.1/33.1 ms

The echo value is just a test for me to see if the $output value is OK.

What I want is that the value before DATA: 33.1/33.1/33.1 ms
shouldn't be viewed in the browser just DATA: 33.1/33.1/33.1 ms

Could someone please help me with this problem?

Best Regards

Peter H�kansson

The problem is that you print the information twice; once in your awk statement; once in your echo statement. One solution is to echo only the word DATA and then execute the ping-awk filter in the same statement (and delete the echo afterwards). There are many other solutions.

Yep -- already asked and answered in another thread: