How can an internet connection be tested without pinging some website? I mean, what if there is a connection but the site is down? Is there a check for a connection with the
This works on both MacOSX and Linux:
#!/bin/bash ping -q -w1 -c1 google.com &>/dev/null && echo online || echo offline