Created
May 12, 2014 17:58
-
-
Save kanazux/03a830c46622722fd63f to your computer and use it in GitHub Desktop.
get iface inet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env/python | |
# -*- coding: utf-8 -*- | |
import re | |
from subprocess import check_output as ck | |
get_ifaces = ck(['/sbin/ifconfig'], shell=1).split() | |
if_ips = [] | |
for item in [re.sub('addr:','',item) for item in get_ifaces if re.match(r'eth[0-9](:[0-9])?|addr:[0-9]',item)]: | |
if item.replace('.','').isdigit(): | |
if_ips[-1].append(item) | |
else: | |
if_ips.append([item]) | |
for item in if_ips: | |
print("\t\n".join(item)+'\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment