Bug#798329: ifconfig: changed output format breaks scripts
Thorsten Glaser
t.glaser at tarent.de
Wed Sep 9 07:30:28 UTC 2015
On Tue, 8 Sep 2015, Guillem Jover wrote:
> Well, the ifconfig implementation in inetutils provides selectable
Oh, there’s another one? I’ve not looked at that one (yet)…
… but then, I really need something that works even with CentOS,
though it (even in version 6, which is way younger than 2003)
has the same output format as jessie.
> > Finally, I have no intentions on maintaining a fork of net-tools to
> > support the 14 years old output format of ifconfig, so I am closing this
> > as wontfix.
>
> This is quite reasonable IMO.
Mh okay. I’m using code similar to the following to catch both
the old and new format (some day I’m going to test inetutils’):
export LC_ALL=C PATH=/bin:/sbin:/usr/bin:/usr/sbin
unset LANGUAGE
hn=$(hostname -f || echo $(hostname).invalid.fqdn)
[[ $hn = *.* ]] || hn=$hn.no.fqdn
lladdr=
test -s /etc/tarent/primary.mac && lladdr=$(cat /etc/tarent/primary.mac)
test -n "$lladdr" || lladdr=$(tgetif | \
sed -ne '/^ *ether \([0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]\)\( .*\)$/s//\1/p' -e '2,$d' -e '/^.* HWaddr \([0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]\)\( .*\)$/s//\1/p' | head -n 1)
ipaddr=$(tgetif | sed -n '/^ *inet \(addr:\)*\([0-9.]*\) .*$/s//\2/p')
netconf=$(/sbin/ip a | tr '\n' '~' | sed 's/~ /= /g' | tr '~' '\n' | fgrep -v vnet | tr '=' '\n' | sed -ne '/^[0-9]*: \([^:@]*\)\(@NONE\)*\([^:]*\):.*$/s//\1\3/p' -e '/inet/s/ scope.*//p' -e '/ link/s/ brd.*$//p'
) || netconf=
Maybe this helps others.
bye,
//mirabilos
--
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
More information about the Pkg-net-tools-maintainers
mailing list