I trying to log my internet connection as it frequently drops out.
So I found this bit of shell script and it works fine when I paste it into my Raspberry Pi command line. I have even tested it by pulling out the phone lead, it does what it is meant to.
wget -q --tries=10 --timeout=20 -O - http://google.com > /dev/null
if [[ $? -eq 0 ]]; then
echo $(date) "1" | tee -a connection.csv
echo $(date) "0" | tee -a connection.csv
So that was good, so saved it as a file, called connection.sh. After half a day head scratching I found out that the dos text format and the unix text format are not identical. Sorted that out with:
sed -i 's/\r$//' connection.sh
It now starts, runs and seems okay. I even have it starting at boot up.
But, when I check the log file I am getting a 0 instead of a 1 when I am connected. I pulled the phone lead, and it still gives a 0.
I downloaded a webpage with wget, it worked fine.
So any ideas what is going on?
Edited by SteamyTea, 09 December 2015 - 06:06 PM.