os.system(cmd)通过执行命令会得到返回值。
ping通的情况下返回值为0。
ping不通的情况:
1、请求超时,返回值1
2、无法访问目标主机,返回值为 0,和ping通返回值相同
 
所以建议不用os.system

python 批量ping脚本不能用os.system的更多相关文章

  1. python 批量ping服务器

    最近在https://pypi.python.org/pypi/mping/0.1.2找到了一个python包,可以用它来批量ping服务器,它是中国的大神写的,支持单个服务器.将服务器IP写在txt ...

  2. Linux批量ping脚本

    根据鸟哥的ping脚本,我重新修改了一下.用到的知识有:read.Linux按行读取.shell输出效果调整等 其中Linux按行读取文件比较重要,可参看文下链接 1 脚本功能: 批量ping当前路径 ...

  3. (21) 树莓派使用python调用命令行 python中调用linux命令及os.system的返回值

    cmd = "sudo shutdown -h now"; os.system(cmd)

  4. python批量执行脚本,使用unittest.TestSuit(); unittest.TextTestRunner().run(); addTest();unittest.defaultTestLoader.discover();

    #alltest.py中内容如下import unittest,osdef all(): #path="D:\\study\\python_api_test\\test1203" ...

  5. [Python陷阱]os.system调用shell脚本获取返回值

    当前有shell个脚本/tmp/test.sh,内容如下: #!/bin/bashexit 11 使用Python的os.system调用,获取返回值是: >>> ret=os.sy ...

  6. shell脚本和python脚本实现批量ping IP测试

    先建一个存放ip列表的txt文件: [root@yysslopenvpn01 ~]# cat hostip.txt 192.168.130.1 192.168.130.2 192.168.130.3 ...

  7. Shell学习笔记之shell脚本和python脚本实现批量ping IP测试

    0x00 将IP列表放到txt文件内 先建一个存放ip列表的txt文件: [root@yysslopenvpn01 ~]# cat hostip.txt 192.168.130.1 192.168.1 ...

  8. Python os.system()调用.sh脚本

    参考: python调用shell脚本的两种方法| Jeff的妙想奇境 已解决--求教python如何调用.sh文件- 查看主题• Ubuntu中文论坛 CODE #!/usr/bin/env pyt ...

  9. python实现批量ping IP,并将结果写入

    最近工作需要,写了一个Python小脚本,分享给大家,因为公司的IP用的差不多了,然后离职人员的IP有没有及时删除,导致没多少IP用了,所以做了一个python脚本跑了跑,清出来一堆ping不通的IP ...

随机推荐

  1. SQL Server数据库中导入导出数据及结构时主外键关系的处理

    2015-01-26 软件开发中,经常涉及到不同数据库(包括不同产品的不同版本)之间的数据结构与数据的导入导出.处理过程中会遇到很多问题,尤为突出重要的一个问题就是主从表之间,从表有外检约束,从而导致 ...

  2. python 10大算法之一 LinearRegression 笔记

    简单的线性回归预测房价 #!/usr/bin/env python # encoding: utf-8 """ @version: @author: --*--. @fi ...

  3. Git permission denied(public key) 解决方法

    1. 在Linux上: # ssh-keygen       ##一定用 id_rsa.pub # cat /root/.ssh/id_rsa.pub 2. copy 整个文件内容到剪切板 3. 打开 ...

  4. 用Margin还是用Padding?(转载)

    转载出自 海玉的博客 本文地址: http://www.hicss.net/use-margin-or-padding/ 用margin还是用padding这个问题是每个学习CSS进阶时的必经之路. ...

  5. python 进程间通信(上)

    一  使用queue来实现进程间的内存共享 #_*_coding:utf-8_*_ from multiprocessing import Process,Queue import os,time d ...

  6. [LeetCode] Bricks Falling When Hit 碰撞时砖头掉落

    We have a grid of 1s and 0s; the 1s in a cell represent bricks.  A brick will not drop if and only i ...

  7. [LeetCode] Kth Largest Element in a Stream 数据流中的第K大的元素

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element ...

  8. idea创建第一个普通java web项目

    1.新建项目(工作空间) 选择空项目 输入项目名称,点击完成 系统会默认选中Modules,点击上面的小+号创建模块->New Module 新建一个Java EE Web Applicatio ...

  9. F#周报2019年第13期

    新闻 Visual Studio 2019发布会 Json2FSharp--在线类型生成器 cs2fs-online--从C#到F#的移植器 AWS Lambda layer上的.NET Core A ...

  10. css学习_css补充知识

    1.渐进增强,优雅降级 2.浏览器前缀 3.背景渐变   4.css  验证工具 2种方式:第2种支持验证本地的css(推荐) 5.css压缩  ----(节约空间,节省带宽) 6.旋转轮播图 案例: ...