Yesterday there was a major catastrophe with my ISP (my computer ISP and the mobile ISP are different) and we didn't have home internet for over 16 hours. So I decided to modify a script a friend wrote for me which to check for internet connection every 15 minutes and depending on the result to display a message in a dialog window.
But the script keeps showing there's no internet connection even now when there is. I took the command from the internet and I can't seem to make it work. I wanna have this script working for the next time the connection dies, as rare as it may be. The problem is that I do have internet connection now, but the script keeps displaying that there isn't, so obviously I'm missing something or doing something wrong.
The basic idea of the script was to ping a local server with just one packet - far from enough to overload the server and yet more than enough to find out whether there's internet connection and its condition.
On top of that, if I run the script through "Automatically started programs", it displays the dialog window twice at once - you click OK to close the message and it turns out there's the same window under it, so you have to click OK again and I can't see a reason why this is happening. The original script - the one that my friend wrote for me - it doesn't do that. So, if you have any suggestions why the second window, that would be great.
Here's the script I modified:
And here's the original script my friend wrote for me, in case you need to see it:
But the script keeps showing there's no internet connection even now when there is. I took the command from the internet and I can't seem to make it work. I wanna have this script working for the next time the connection dies, as rare as it may be. The problem is that I do have internet connection now, but the script keeps displaying that there isn't, so obviously I'm missing something or doing something wrong.
The basic idea of the script was to ping a local server with just one packet - far from enough to overload the server and yet more than enough to find out whether there's internet connection and its condition.
On top of that, if I run the script through "Automatically started programs", it displays the dialog window twice at once - you click OK to close the message and it turns out there's the same window under it, so you have to click OK again and I can't see a reason why this is happening. The original script - the one that my friend wrote for me - it doesn't do that. So, if you have any suggestions why the second window, that would be great.
Here's the script I modified:
Code:
#!/bin/bash
while [ 0 -eq 0 ]
do
packet=$(ping -c 1 abv.bg | grep "packet loss")
if [ "packet loss" == 0% ]
then
echo "Internet connection is OK!"
else
zenity --info --text "No connection. I'll try again in 15 minutes." --width="400" --title="Internet check"
fi
timeout 900
done
And here's the original script my friend wrote for me, in case you need to see it:
Code:
#!/bin/bash
while [ 0 -eq 0 ]
do
CHECK="$(curl -s https://archlinux.org/packages/extra/x86_64/nvidia/ | grep '<h2>nvidia')"
CHECK2="$(echo $CHECK | sed 's/<h2>//g' | sed 's/<\/h2>//g')"
CHECK3="$(echo $CHECK2 | wc -m)"
if [ $CHECK3 -ge 19 ]
then
echo "$CHECK2, I'll check again in a week."
else
zenity --info --text "A stable nvidia driver is available!\n<b>$CHECK2</b>" --width="400" --title="nvidia driver check"
fi
sleep 604800
done