diff options
| -rwxr-xr-x | bin/network_info | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/network_info b/bin/network_info index b9b46dd..9c20b89 100755 --- a/bin/network_info +++ b/bin/network_info @@ -38,9 +38,10 @@ def get_ip_address(interface): struct.pack('256s', interface[:15].encode()) )[20:24]) + def get_ipv6_address(interface): cmd = ['/sbin/ip', '-6', 'addr', 'show', 'dev', interface] - proc = subprocess.check_output(cmd,universal_newlines=True) + proc = subprocess.check_output(cmd, universal_newlines=True) ipaddr = proc.split()[8].strip() return ipaddr @@ -63,14 +64,14 @@ def main(args): print("Interface: %s" % interface) print("Connected: %s" % connected) try: - print("IPv4: %s" % get_ip_address(interface)) + print("IPv4: %s" % get_ip_address(interface)) except IOError: print("IPv4: n/a") - try: - print("IPv6: %s" % get_ipv6_address(interface)) + try: + print("IPv6: %s" % get_ipv6_address(interface)) except IOError: print("IPv6: n/a") - except: + except: print("IPv6: n/a") print("MAC: %s\n" % get_mac_address(interface)) |
