WiFi down notification

While in Berlin I was downloading some large files for a project I was working on & kept having a problem where the wifi at the hotel kept automatically logging out. So I wrote this short shell script to notify me when I needed to log back in again. Just save it to a file named "checker.sh". chmod the file so it can be executed with "chmod u+x checker.sh". Then just run it from the command line with "./checker.sh".

while [ 1 ];
  echo "startup"
  for myHost in $HOSTS
    count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    if [ $count -eq 0 ]; then
      # 100% failed 
      echo "Host : $myHost is down (ping failed) at $(date) ^G"
      # Let us know when the connection is down 
      # (on OSx swap 'espeak' for 'say')
      espeak "wifi is down"


Post new comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h2> <h4> <img> <div> <table> <tr> <td> <pre>
  • Lines and paragraphs break automatically.
  • Insert image: [img:node_id align=(left|right) size=(|fullLA|fullPreview|fullSQ|halfLA|halfPO|halfSQ|thirdSQ) action=(popup|link|frame) url=url style="margin:10px;" title=text description=text]

More information about formatting options

info@theanthillsocial.co.uk XHTML 1.0 Strict CSS2 WAI