[X-Unix] shell script - online or not?

Charles Howse chowse at charter.net
Fri Jun 2 08:55:02 PDT 2006


Hi,
My cable modem has developed a habit of dropping the connection, and  
I want to document the dates and times that I am offline so I will  
have some leverage with tech support.
The following script checks the current state of the connection, and  
compares it to the last  line of the results file, but I'm not  
getting the results I expected.
When it runs, and I am offline, the terminal output is:

[charles at larry:~]$ bin/pings2.sh
5 packets transmitted, 0 packets received, 100% packet loss
5 packets transmitted, 5 packets received, 0% packet loss

As you can see, the strings are not equal, but the script is not  
writing to the file.
I have even commented the script to echo "equal" or "different", no joy.

What might I be doing wrong?


#!/bin/bash
#
test= ping -c 5 24.159.64.20 | grep packets
look= tail -n 1 Desktop/ping_results.txt
if [ "$test" == "$look" ] ; then
	:
else
	echo >> Desktop/ping_results.txt
	date >> Desktop/ping_results.txt
	$test >> Desktop/ping_results.txt
	
fi

--
Thanks,
Charles
http://bubbabbq.homeunix.net




More information about the X-Unix mailing list