在继续进行bash之前等待网络链接建立 [英] Waiting for network link to be up before continuing in bash
本文介绍了在继续进行bash之前等待网络链接建立的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在继续之前检查bash脚本中多个接口的网络接口链接是否成功?
Is there a way to check for successful network interface link for multiple interfaces in a bash script before continuing?
类似的东西:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
推荐答案
您可以检查运行ifconfig -s
后网络接口的名称是否出现.
You can check if the network interfaces' names appear after running ifconfig -s
.
类似的东西:
if [ $( ifconfig -s | grep eth0 ) ]; then echo "eth0 is up!"
检查 此链接 了解更多信息.
Check this link for more details.
要继续进行此测试,您可以执行@ jm666所说的操作:
To make this test ongoing, you can do something like what @jm666 said:
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
这篇关于在继续进行bash之前等待网络链接建立的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文