I have written the following system command to ping a website which gives me desired ICMP response.
response = system("ping -c1 www.stackoverflow.com")
The response is as--
PING stackoverflow.com (64.34.119.12) 56(84) bytes of data.
64 bytes from stackoverflow.com (64.34.119.12): icmp_req=1 ttl=52 time=336 ms
--- stackoverflow.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 336.699/336.699/336.699/0.000 ms
=> true
Now i want to store the average time from the above statistics. So i hit the next system command which is as.
response_time = system("ping -c 1 www.pintile.com | tail -1| awk '{print $4}' | cut -d '/' -f 2")
This gives me the average time but does not store it in the response_time variable. Tha value stored in response_time is true.
335.898
=> true
Now my question is How to store the average time in the response_time variable??