[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Can we kill net-tools, please?



On Thu, Dec 29, 2016 at 2:38 PM, Russ Allbery <rra@debian.org> wrote:
> Also, this is not at all easy to parse:
>
> # ip -o address
> 1: lo    inet 127.0.0.1/8 scope host lo\       valid_lft forever preferred_lft forever
> 1: lo    inet6 ::1/128 scope host \       valid_lft forever preferred_lft forever
> 3: wlan0    inet 192.168.0.195/24 brd 192.168.0.255 scope global dynamic wlan0\       valid_lft 598191sec preferred_lft 598191sec
> 3: wlan0    inet6 fe80::a288:69ff:fe31:2b62/64 scope link \       valid_lft forever preferred_lft forever
>
> The fields aren't labeled, you have to make a bunch of assumptions about
> ordering, the backslash thing is just completely bizarre and makes the
> parsing way harder (see the "lo\" on the first line)... this is really
> rather dire.

i recently had to parse it (in particular, `ip -s -s -s -s -o link
show up`) it's not that hard: split by \, remove the first line,
remove any spurious other lines, then parse by line pairs: the first
is the headers, the second the values, and so on (kinda OT but yeah a
YAML/JSON/anything would have been better, but it's doable)

-- 
Sandro "morph" Tosi
My website: http://sandrotosi.me/
Me at Debian: http://wiki.debian.org/SandroTosi
G+: https://plus.google.com/u/0/+SandroTosi


Reply to: