getting ping results


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting ping results
# 1  
Old 12-13-2009
getting ping results

hello

i have single file that contains many ping results. that file looks like that :
Code:
PING www.pwr.wroc.pl (156.17.193.13) 56(84) bytes of data.
64 bytes from www.pwr.wroc.pl (156.17.193.13): icmp_seq=1 ttl=241 time=395 ms

--- www.pwr.wroc.pl ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 395.412/395.412/395.412/0.000 ms
PING www.pwr.wroc.pl (156.17.193.13) 56(84) bytes of data.
64 bytes from www.pwr.wroc.pl (156.17.193.13): icmp_seq=1 ttl=241 time=192 ms

--- www.pwr.wroc.pl ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 192.677/192.677/192.677/0.000 ms
PING www.pwr.wroc.pl (156.17.193.13) 56(84) bytes of data.

--- www.pwr.wroc.pl ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
PING www.pwr.wroc.pl (156.17.193.13) 56(84) bytes of data.
64 bytes from www.pwr.wroc.pl (156.17.193.13): icmp_seq=1 ttl=241 time=229 ms
--- www.pwr.wroc.pl ping statistics ---
 1 packets transmitted, 1 received, 0% packet loss, time 0ms
 rtt min/avg/max/mdev = 229.677/229.677/229.677/0.000 ms

how to make ping results into another file in specific way :
Code:
395
192
0
229

i made script for non counting packets loss, it looks like that :
Code:
grep -o e=[0-9]*.[1-9] ping_results.txt | sed  's#[e]##' | sed 's#[=]##' > ping_numbers.txt

its lame, but i dont know how to use only one sed :/ but it works Smilie

but how to add time 0? in this case i mean packet has not arrived
# 2  
Old 12-13-2009
This might work:
Code:
awk -F'[ =]' '/100% packet loss/{print 0}/bytes from/{print $11}' ping_results.txt

(Why do you want to use the value 0 by the way? You would have to leave them out of the calculations or they would pollute the results, no?)
# 3  
Old 12-13-2009
thanks Scrutinizer, it works perfect. im making time chart and i need all values. it corelates with tracert results so it is important.

thanks a lot once again
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies

2. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

3. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

4. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies

5. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

6. Linux

Not able to ping

Hi All, Need your help one more time. I am trying to ping a linux machine which is not responding to ping. However traceroute can reach the machine and I can log in to it by ssh. I have checked /proc/sys/net/ipv4/icmp_echo_ignore_all it is already set as "0". It is not happening in the... (1 Reply)
Discussion started by: ailnilanjan
1 Replies

7. Shell Programming and Scripting

can ping doing this?..

i have question about this problem,, could i ping ip address with the range 192.168.1.1 - 192.168.2.200 ? ip address begin from 192.168.1.1 until 192.168.2.200 ? could ping (not fping) doing that? (5 Replies)
Discussion started by: demhyt
5 Replies

8. IP Networking

can't ping by ip

hi, I m trying to ping ip on the network . The machine is started but i can't access and can't ping it .. But when i restarts that machine that works fine..... can anybody have an idea about this problem ?? if then reply .. thanks (2 Replies)
Discussion started by: tahir23
2 Replies

9. UNIX for Advanced & Expert Users

can't ping IP

hi , i have problem that i can't ping machine , machine is in running state but i can't access or ping it .. but when i restarts that machine it works fine. can anybody have an idea abou this problem .. thanks (1 Reply)
Discussion started by: tahir23
1 Replies

10. UNIX for Dummies Questions & Answers

ping

Hi there hope list can help I'm looking for a command that does the following lets say i ping a server 00.00.000.00 and this server is up and running how do i get the ping command to return a UP or a Down meaning if the command is true do this if the command is False do this ... (2 Replies)
Discussion started by: nemex
2 Replies
Login or Register to Ask a Question