在繼續之前,有沒有辦法在bash腳本中檢查多個接口的成功網絡接口鏈接?等待網絡鏈接繼續之前在bash中
喜歡的東西:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
在繼續之前,有沒有辦法在bash腳本中檢查多個接口的成功網絡接口鏈接?等待網絡鏈接繼續之前在bash中
喜歡的東西:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
如果運行ifconfig -s
後的網絡接口的名字出現在你可以檢查。
喜歡的東西:
if [ $(ifconfig -s | grep eth0) ]; then echo "eth0 is up!"
檢查this link瞭解更多詳情。
爲了使這個測試正在進行中,你可以做一些像什麼@ jm666說:
while ! ping -c 1 -W 1 1.2.3.4; do
echo "Waiting for 1.2.3.4 - network interface might be down..."
sleep 1
done
在一個循環
如果我只想測試一次,這很好,但如果我需要主動等待,直到它聯機然後繼續,該怎麼辦? – user1527227
好的,編輯我的答案 –
爲什麼你在那裏有一個'-W'標誌?您沒有爲單個ping指定超時...... – user1527227
嘗試1X每第二個ping到一些著名主持人什麼是每個網絡中,或者檢查ifconfig輸出... – jm666
如果它們啓動,它並不一定意味着其他主機響應ping。 – LtWorf