Monday, 30 September 2013

python search for ipaddress

import os
import re
s=os.popen("ifconfig")
for i in s.readlines():
    switch=re.search( r"(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})", i, re.M|re.I)
    if switch:
        print (switch.group())

No comments:

Post a Comment