Sometimes it is necessary to check whether server you want to run some big bash script is connected to Internet. Usually it makes sense while running scripts periodically using cron. Below is the tiny bash script for this purpose:
#!/bin/bash WGET="/usr/bin/wget" $WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null if [ ! -s /tmp/index.google ];then echo "no" else echo "yes" fi
As you see it tries to download google’s index page, if it’s not empty script returns “yes”, if there is not Internet connection available script will return “no”. If it is impossible to fetch the page in more than 5 seconds script will return “no” as well.
Anything to add? You are welcome!
Pingback : ?? ?? Newsletter Content – Using Leverage To Find Inspiration I | feel badd chanbrel assd
Pingback : Ray Ban Wayfarer MHICHM5391 SZNC038629 | Angel6mVn's Blog
Pingback : Ray Ban Wayfarer WMJKCM6985 JMZR361063 | Angel5bTn's Blog
Pingback : ?????? ??ylrZU | sale70wc
Pingback : ????nJmiE | N2RIrKsOK
Pingback : ?????? ??3LNyN | asfgvr36ba
Pingback : ??? ?? sAa17 | ayxel7az
Pingback : Ray Ban Outlet CIBVYC9682 CJES110849 | Angel6jHv's Blog
Pingback : ???duGqO | asdwgvd09ue
Pingback : Typically the Islamic Movements | ghjghukhgkhgjm
Pingback : right away | ghjghukhgkhgjm
Pingback : ?????? ?? GQoCb | lEvvitn8t
Pingback : ?????? ?? n34EH | e3QxjO7
Pingback : Doll Idea | adidas wings 2096oQ
Pingback : ?????? ?? HAcrL | etenjRi