This 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.