python 批量ping一个网段 返回结果 的程序
来源:互联网 发布:caffe咖啡 编辑:程序博客网 时间:2024/04/20 00:28
import subprocessimport threadingimport timeimport reip_num = 256list_ping_result = []class PingThread(threading.Thread): def __init__(self,str_ip,sleep_time,g_list_p_r): threading.Thread.__init__(self) self.sleep_time = sleep_time self.str_ip = str_ip self.list_p_r = g_list_p_r def run(self): time.sleep(self.sleep_time) ftp_sub = subprocess.Popen("ping %s -n 3" % self.str_ip, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) ret = ftp_sub.stdout.read() str_ret = ret.decode("gbk") ret_s = re.search("TTL",str_ret) if ret_s: self.list_p_r.append(('ping ok',self.str_ip)) else: self.list_p_r.append(('ping error',self.str_ip)) def cmp_s(toupe_str): str_val = toupe_str[1] ret_group = re.match("\d*",str_val[::-1]) str_ret = ret_group.group() return int(str_ret[::-1])thread_id =[]for i in range(ip_num): thread_id.append(0) thread_id[i] = PingThread("192.168.8.%d" % i, int(i/20),list_ping_result) thread_id[i].start() print(i,end='')while True: if len(list_ping_result) >= ip_num: list_ping_result.sort(key=cmp_s) for i in list_ping_result: print(i) break
0 0
- python 批量ping一个网段 返回结果 的程序
- pyqt 批量ping一个网段 返回结果 的程序 (加了个界面 效果不理想)
- Python: ping网段内所有ip并返回结果
- PING 一个网段
- DOS的FIND及ping一个网段内的机器
- 一个批量修改文件名的Python程序
- 一个批量修改文件名的Python程序
- 跨网段ping的过程
- 跨网段的ping过程
- 当能电脑能够ping通同一个网段的ip,却ping不通网关的解决方法
- python 写一个Mythread能返回线程执行的结果
- Python获取网段内ping通IP
- python获取PING结果
- 一个Ping结果
- Python 的一个 ping 脚步
- 同个网段和不同网段的ping过程
- 一个批量转换文本文件编码的程序(Python)
- 一个批量转换文本文件编码的程序(Python)
- 波特词干算法
- 关于ConcurrentHashMap中并发Level数目的问题
- Cocos2dx3.3Final(3)Button常用成员函数(C++)
- sqlite3数据库增删改查通用类swift
- OS开发UI篇—iOS开发中三种简单的动画设置
- python 批量ping一个网段 返回结果 的程序
- sublime 在本地服务器打开
- 图片封装下载——同步下载
- 【UIKit-110-5】#import <UIKit/UITableView.h>选中行
- 快速幂函数
- iOS开发UI篇—UIScrollView控件介绍
- 母亲走了四周年
- POJ 3764 The xor-longest Path
- ORACLE增删改查