X-Git-Url: http://git.grml.org/?p=grml-shlib.git;a=blobdiff_plain;f=sh-lib;fp=sh-lib;h=e87b9cb1074b4ccb66667a6d23a53708a40f9393;hp=19755851470772327eb3f701db9d579279c61e75;hb=33e1c3a3f197409cedfc925c4ddd2db66881eb50;hpb=8df768e2d182a600cdc44dc1c4b10a9dc34b2737 diff --git a/sh-lib b/sh-lib index 1975585..e87b9cb 100644 --- a/sh-lib +++ b/sh-lib @@ -515,7 +515,11 @@ netGetNetmask() local ret_='' setCLang - nm_=`ifconfig "$iface_" | awk '/[Mm]ask/{FS="[: ]*"; $0=$0; print $8; exit}'` + if ifconfig "$iface_" | grep -qi 'Mask:' ; then # old ifconfig output: + nm_=$(ifconfig "$iface_" | awk '/[Mm]ask/{FS="[: ]*"; $0=$0; print $8; exit}') + else # new ifconfig output (net-tools >1.60-27): + nm_=$(ifconfig "$iface_" | awk '/netmask/{print $4}') + fi ret_=$? restoreLang if [ -z "$nm_" ]; then @@ -542,8 +546,7 @@ netGetIp() local ret_="" setCLang - #ip_=`ip addr list eth0 |mawk '/inet/{split($2,A,"/"); print A[1]}'` - ip_=`ifconfig "$iface_" | awk '/[Ii]net [Aa]ddr/{FS="[: ]*"; $0=$0; print $4; exit}'` + ip_=$(ip addr show dev "$iface_" | awk '/inet /{split($2,a,"/"); print a[1]}') ret_=$? restoreLang if [ -z "$ip_" ]; then