您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
#!/usr/bin/env python #-*- coding: UTF-8 -*- import platform import sys import os import time import thread def get_os(): # get os os = platform.system() if os == "Windows": return "n" else: return "c" def ping_ip(ip_str): #ping ip cmd = ["ping", "-{op}".format(op=get_os()), "1", ip_str] output = os.popen(" ".join(cmd)).readlines() flag = False for line in list(output): if not line: continue if str(line).upper().find("TTL") >= 0: flag = True break if flag: print "ip: %s is ok ***" % ip_str def find_ip(ip_prefix): #find all ip of the net for i in range(1, 256): ip = '%s.%s' % (ip_prefix, i) thread.start_new_thread(ping_ip, (ip,)) time.sleep(0.3) if __name__ == "__main__": print "start time %s" % time.ctime() commandargs = sys.argv[1:] args = "".join(commandargs) ip_prefix = '.'.join(args.split('.')[:-1]) find_ip(ip_prefix) print "end time %s" % time.ctime()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。