while ! ping -W 1 -c 4 www.google.com >& /dev/null ||
! ping -W 1 -c 4 www.yahoo.com >& /dev/null; do
Though I'd just test connectivity to an IP address; 220.127.116.11 is Google's public DNS server (it has very high availability). Testing whether DNS works is unreliable anyway because the entry may be in the cache.
while ! ping -W 1 -c 1 18.104.22.168 >&/dev/null; do sleep 600; done
Ping isn't always the best way to check internet connectivity. Many places (especially enterprise networks) block all but web access. You can test whether the web is working by downloading a file from a high-availability server. This tests DNS as well, at least from the HTTP proxy's point of view (which again is often what matters).
while ! wget -q -O /dev/null --no-cache http://www.google.com/; do sleep 6000; done