Below is my script to store the ping result on a text file, but the result stored in the output file is not complete, it is missing the last statement where ping stats are shown. Can anyone help in this?
Script:
#!/bin/bash
cp /dev/null /etc/scripts/ping-results.txt
fping -c5 -t50 192.168.10.1 >>/etc/scripts/ping-results.txt
#fping -c10 -t50 202.141.253.139 | perl -nle 'print scalar(localtime), " ", $_' >>/etc/scripts/ping-results.txt
Output when script is run:
root@noc-tst:/etc/scripts# ./ping-test.sh
192.168.176.54 : xmt/rcv/%loss = 5/5/0%, min/avg/max = 19.2/19.5/20.4
Output File (ping-results.txt):-
Tue Aug 6 00:12:10 2013 192.168.176.54 : [0], 84 bytes, 19.2 ms (19.2 avg, 0% loss)
Tue Aug 6 00:12:11 2013 192.168.176.54 : [1], 84 bytes, 19.3 ms (19.2 avg, 0% loss)
Tue Aug 6 00:12:13 2013 192.168.176.54 : [2], 84 bytes, 19.5 ms (19.3 avg, 0% loss)
Tue Aug 6 00:12:14 2013 192.168.176.54 : [3], 84 bytes, 19.3 ms (19.3 avg, 0% loss)
Tue Aug 6 00:12:15 2013 192.168.176.54 : [4], 84 bytes, 19.5 ms (19.4 avg, 0% loss)