How to check internet access using bash script in linux?

前端 未结 10 1195
孤街浪徒
孤街浪徒 2021-02-01 06:43

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

10条回答
  •  情话喂你
    2021-02-01 07:22

    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
    

提交回复
热议问题