In my school, the internet is not available(every night after 23:0 the school will kill the internet, to put us in bed >..<), then the ping will never stop, though I have use
Install fping: > less problem then ping.
fping google.com | grep alive
to use for example like:
#!/bin/bash itest=$(fping google.com | grep alive) while [ "$itest" == "" ] do sleep 5 itest=$(fping google.com | grep alive) done echo now online