
我们代码已经用ping -c1了,主要是为了等待。 不需要那么多ping包。
你有看到关于-W与exit code的关系吗? 反正man page里只描述了-w情况下的exit code.
looks they have the same result. test -w: [root@d63bac6cf0b3 /]# ping -c 1 -w 1 114.114.114.114 > /dev/null; echo $? 0 [root@d63bac6cf0b3 /]# ping -c 1 -w 1 1.2.3.4 > /dev/null; echo $? 1 [root@d63bac6cf0b3 /]# ping -c 1 -w 1 baidu.com > /dev/null; echo $? ping: baidu.com: Name or service not known 2 test -W [root@d63bac6cf0b3 /]# ping -c 1 -W 1 114.114.114.114 > /dev/null; echo $? 0 [root@d63bac6cf0b3 /]# ping -c 1 -W 1 1.2.3.4 > /dev/null; echo $? 1 [root@d63bac6cf0b3 /]# ping -c 1 -W 1 baidu.com > /dev/null; echo $? ping: baidu.com: Name or service not known 2
我们代码已经用ping -c1了,主要是为了等待。 不需要那么多ping包。
understood it, -w(deadline) is certainly more appropriate than -W(timeout). :) -------- Thanks Yu Chuan
Thanks, Fengguang