I’m working with the Command Line API. The output for multiline results usually is pretty-printed, with nice boxes, headers etc. Great for readability. However, I need to parse the output for a python app. Do I really have to filter out all the heading, dashes etc, or is there an option that results in plain, hopefully delimited, ASCII output? Can’t find it in the dox.
Remember: CLI interface, not remote. Thank you!
It would be better if there was a command line option that returned the data as xml or json which would be much easier to parse but I dont think the current out put can be formatted that way. Perhaps this should be added to the developers to do list
There is always a --multiline flag that produces a much more easily parsable format. It’s not JSON, but should be simple to handle in Python because it’s always like :
We do also support JSON format when using the remote API, which does the conversion from the Virtualmin format above automatically with the json=1 parameter. I’d generally recommend using the remote API for scripts actually, since it means the script doesn’t have to run as root.
After further code improvements, we updated the parameters to output the same format as the remote API. The parameter names were also changed to --json and --xml for the CLI.