On Sun, Mar 11, 2012 at 15:43, Chris Dennis <cgden...@btinternet.com> wrote: > Hello folks > > I'm hacking together a quick script to parse the output from the 'ip' > command on Linux, e.g. > > $ ip a s > 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN > link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 > inet 127.0.0.1/8 scope host lo > inet6 ::1/128 scope host > valid_lft forever preferred_lft forever > 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen > 1000 > link/ether 00:19:b9:06:4c:86 brd ff:ff:ff:ff:ff:ff > inet 192.168.1.7/24 brd 192.168.1.255 scope global eth0 > inet6 2001:dead:beef:cafe::1/64 scope global dynamic > valid_lft 86147sec preferred_lft 14147sec > inet6 fe80::1/64 scope link > valid_lft forever preferred_lft forever > > -- which is straightforward. But then I need to process the IPv6 addresses > to be able to extract subnet prefixes etc.
$ /sbin/ifconfig | perl -MRegexp::IPv6=\$IPv6_re -lne '/(?:($IPv6_re)(\/\d+))/ and print "net $1 size $2"' net fe80::fcff:ff:fe00:5272 size /64 net ::1 size /128 HTH, Paul > > CPAN has so many IPv6-mangling modules that I don't know which to choose, or > which will emerge as the best/most stable etc. in the future. Certainly > some of the ones I've looked at are badly written or badly documented or > just plain broken. > > Any recommendations? > > cheers > > Chris > -- > Chris Dennis cgden...@btinternet.com > Fordingbridge, Hampshire, UK