aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-11-06 16:45:22 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-11-06 16:45:22 +0100
commitd1b0fa6b2ffa33263fb699a4aea6cc9f6cc8e1b9 (patch)
tree106a33843dc67f0b6cdc46b304d24cfd4d5914fd
parente4aa5cc08f8d9c013d5d7f43c24cb9d4f95febcf (diff)
downloadstandardskriver-d1b0fa6b2ffa33263fb699a4aea6cc9f6cc8e1b9.tar.gz
standardskriver-d1b0fa6b2ffa33263fb699a4aea6cc9f6cc8e1b9.tar.bz2
standardskriver-d1b0fa6b2ffa33263fb699a4aea6cc9f6cc8e1b9.zip
standardskriver: Use ip command (rather than deprecated ifconfig) to obtain local IP addresses.
-rwxr-xr-xstandardskriver5
1 files changed, 3 insertions, 2 deletions
diff --git a/standardskriver b/standardskriver
index 7c82f68..230ce3b 100755
--- a/standardskriver
+++ b/standardskriver
@@ -109,13 +109,14 @@ hostnames = []
hostnames.append(gethostname())
hostnames.append(getfqdn())
-re_ipaddr = re.compile(r'inet addr:(\S+)')
+re_ipaddr = re.compile(r'inet (\S+)/')
ipaddrs = []
try:
ipaddrs.append(os.environ['SSH_CLIENT'].split()[0])
except KeyError:
pass
-p = subprocess.Popen(['/sbin/ifconfig'], env={'LANG': 'C'}, stdout=subprocess.PIPE)
+
+p = subprocess.Popen(['/usr/bin/ip', 'a'], env={'LANG': 'C'}, stdout=subprocess.PIPE)
for line in p.stdout:
m = re_ipaddr.search(line.decode())
if m: