Saturday, November 15, 2014

find ip address from file

[root@web ~]# cat findip.py
#!/usr/bin/python
import re
import os
reg = re.compile('\s?\d+\..+\..+\.\d+',re.IGNORECASE)
filename = "/root/eli"
f1 = open(filename,'r')
#for searchstr in f1.readlines():
#    search1 = reg.findall(searchstr)
#    print search1
#print "END"

for test in f1.readlines():
    search2 = reg.finditer(test)
    for i in search2:
        print i.group().strip()

f1.close()
print "END"

No comments:

Post a Comment