【Ping】unix - ping命令的退出状态

原文:
If ping does not receive any reply packets at all it will exit with code 1.
If a packet count and deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it will also exit with code 1.
On other error it exits with code 2. Otherwise it exits with code 0. This makes it possible to use the exit code to see if a host is alive or not.

谷歌翻译:
如果ping根本没有收到任何回复数据包,它将退出代码1。
如果指定了数据包计数和截止日期,并且在截止日期到达时收到的包数量少于计数数据包,则也会以代码 1 退出。
在其他错误中,它与代码2一起退出。否则它将退出代码0。这使得使用退出代码查看主机是否还活着成为可能。

猜你喜欢

转载自blog.csdn.net/qq_22227087/article/details/115321096