This will run ifconfig and check for active interfaces. Note that all interfaces seem to be up in OS X, whether they are actually connected to a network or not. If it doesn't find any, it will abort the script, thus not hanging forever.