|
|
|
|
|
by nailer
3627 days ago
|
|
This is good, but the data structures - eg arrays of arrays - don't really match the underlying data. Imagine what 'ip addr' or 'ifconfig' would look like - they output paragraphs rather than lines, so scraping lines wouldn't produce good output. It'd be better - and FAR more work - to make an object pipeline based powershell equivalent for Nix, based on JSON. You could write cmdlets in any language that outputs JSON and do better at this project's goal of avoiding scraping. ps node | select pid
instead of: ps().find(function(line){ return line[3] === 'node' })[0]
Since the fields have keys, you avoid magic numbers and the code's easier to read.(you could of course alias those to make 'pidof node' like Linux distros do) The end result would be much better than Powershell, since it would use JSON and not be tied to .net languages. |
|