发上等愿,结中等缘,享下等福;择高处立,寻平处住,向宽处行

Brick walls are there for a reason :they let us prove how badly we want things

代码改变世界

python 批量ping脚本不能用os.system

2015-02-13 16:01  糖兜guard  阅读(1240)  评论(0编辑  收藏  举报
os.system(cmd)通过执行命令会得到返回值。
ping通的情况下返回值为0。
ping不通的情况:
1、请求超时,返回值1
2、无法访问目标主机,返回值为 0,和ping通返回值相同
 
所以建议不用os.system

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things