Just outout an IP address of an interface?
Just outout an IP address of an interface?
Posted Jan 13, 2017 22:54 UTC (Fri) by Cyberax (✭ supporter ✭, #52523)In reply to: Just outout an IP address of an interface? by zlynx
Parent article: Moving on from net-tools
Posted Jan 13, 2017 23:17 UTC (Fri)
by zlynx (guest, #2285)
[Link] (4 responses)
And seriously, someone wanted JSON output? JSON is almost impossible to deal with in bash. The only tool I've seen that makes it possible is "jq", and I had to build that manually since Fedora didn't ship it. Although I see it is in the repos for F25 so they finally got it.
So processing the text output of ifconfig or ip is really the bash way to get it done. That's how everything gets done in bash.
Posted Jan 13, 2017 23:20 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
JSON is extremely easy to parse and tools to do it are now built-in into various languages. On the other hand, calling the kernel and then parsing complicated structures is often fraught with problems.
Posted Jan 13, 2017 23:59 UTC (Fri)
by zlynx (guest, #2285)
[Link] (2 responses)
And this, which is more modern:
I'm not going to look up Ruby, but I know Perl has similar modules, because I used one in the past (2005'ish)
Posted Jan 14, 2017 0:06 UTC (Sat)
by Cyberax (✭ supporter ✭, #52523)
[Link] (1 responses)
And anyway, why would you make a Linux tool that is user-hostile to scripting users? I understand that people might not have been thinking about it 10 years ago, but defending this like it's a good thing - that's just stupidity.
Posted Jan 14, 2017 21:09 UTC (Sat)
by zlynx (guest, #2285)
[Link]
Posted Jan 14, 2017 4:54 UTC (Sat)
by lsl (subscriber, #86508)
[Link]
You use ifdata(1). Moreutils are quite useful.
Just output an IP address of an interface?
Just output an IP address of an interface?
Just output an IP address of an interface?
http://stackoverflow.com/questions/166506/finding-local-i...
https://pypi.python.org/pypi/pyroute2/
https://github.com/svinota/pyroute2
Just output an IP address of an interface?
Just output an IP address of an interface?
Just outout an IP address of an interface?