Capture last 3 lines from ping output
Posted: Sat May 23, 2009 9:53 am
Hi Guys,
I am building a network utility for my company to record the output of ping and traceroute results and put them in a database. Our manager will log into an admin section and run a report to see the summary of the ping and traceroute results.
I am able to store the output of the ping command in a variable. The output looks like this
My Account
Logged as alex.dehaini@teledataict.com | Settings | PingTest | SpeedTest | Logout
Ping Output:
Any help would be greatly appreciated
I am building a network utility for my company to record the output of ping and traceroute results and put them in a database. Our manager will log into an admin section and run a report to see the summary of the ping and traceroute results.
I am able to store the output of the ping command in a variable. The output looks like this
My Account
Logged as alex.dehaini@teledataict.com | Settings | PingTest | SpeedTest | Logout
Ping Output:
I store the entire output in a variable. Now. I want to store only the last 3 lines in a variable i.e.PING 41.211.5.178 (41.211.5.178) 56(84) bytes of data.
64 bytes from 41.211.5.178: icmp_seq=1 ttl=254 time=1.18 ms
64 bytes from 41.211.5.178: icmp_seq=2 ttl=254 time=1.35 ms
64 bytes from 41.211.5.178: icmp_seq=3 ttl=254 time=1.11 ms
64 bytes from 41.211.5.178: icmp_seq=4 ttl=254 time=1.09 ms
--- 41.211.5.178 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 1.096/1.189/1.359/0.108 ms
I was wondering if there is a function or some regular expression I could use to capture only the last 3 lines.--- 41.211.5.178 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 1.096/1.189/1.359/0.108 ms
Any help would be greatly appreciated