Simpe BASH wrapper script to test if you’re online or not

technology.pngThis falls squarely in the “small annoyances” category. More and more wifi hotspots will let you connect – but not access anything until you log in. Sometimes, I don’t bother to – I’m not doing anything online.

That doesn’t stop cron jobs from trying to connect to the internet.

So I wrote a small wrapper script to test and see if you can find the WAN IP address. It connects to checkip.dyndns.org (using wget), and uses SED to parse out the IP address. If you’re not connected, you’ll get garbage back – which won’t fit the length parameters of an IP address.1

Just call this script with all the parameters and whatnot that you would your other program (yes, all of them, it passes them all in one fell swoop), and if you’re not connected – it doesn’t run. Saves you error messages in the logfile, and lets you get on with your day.

You can find the script at Pastebin, here.
1Yes, it doesn’t error check. I said it was simple.

blankWas this post helpful or insightful? Buy me a coffee here or here and share this post with others!

Popular posts:

  • The difference between boundaries and rules
  • Two Ways to get CMYK Separation Using GIMP Instead of Photoshop in 2022
  • Weekend Project: Whole House and Streaming Audio for Free with MPD
  • Organizing and Tiling Your Windows on #Openbox Using Only... Openbox
  • If there's one Nazi (or a racist) at the table...
  • Odds and Ends: Optimizing SSHFS, moving files into subdirectories, and getting placeholder images

Recent Posts