Hello, I am writing a script that is going to ping a remote host but I want the user to be able to enter in the interval and size when he runs the program. For example the user would enter this to initialize the script.
./mping -i 0.05 -s 804
The code that I have running so far is:
#!/bin/bash
host=db.macom.com
ping $host $1 $2 $3 $4
ok so now for example my output is:
64 bytes from host: icmp_seq=0 ttl=64 time=2.22 ms
64 bytes from host: icmp_seq=1 ttl=64 time=0.537ms
64 bytes from host: icmp_seq=2 ttl=64 time=0.575 ms
64 bytes from host: icmp_seq=3 ttl=64 time=0.585 ms
64 bytes from host: icmp_seq=4 ttl=64 time=0.578 ms
And then once the ping either times out or the user presses cntrl C you get
5 packets transmitted, 5 received, 0% packet loss, time 12009ms
etc...
My question is how do I reference that number of packets transmitted and received so that I can calculate if they are equal or not. I know i would put those values into variables but what do I set each variable equal too?