#coding:utf-8
import sys, socket
import os

if os.path.exists("input_ips.txt"):
    f = open("input_ips.txt")
    ips = f.readlines()
    for ip in ips:
        IP = ip.strip()
        try:
            result = socket.gethostbyaddr(IP)
            # print "Primary hostname:"
            print IP.ljust(15," ") + " --> ".center(3," ") + result[0]
        except Exception, e:
            print IP.ljust(15," ") + " --> ".center(3," ") + IP
else:
    print "Please input your IPS in input_ips.txt"
    with open("input_ips.txt",'a') as  input:
        input.write("Please input your IPS here.")

发表评论

电子邮件地址不会被公开。 必填项已用*标注