CLI API output parsing (character escaping?)

While using the DnsRecord::queryRecords feature, I noticed the output from the CLI is tab delimited. I know the PHP API will return an array of information, so it appears the output is taking that array and echoing the records delimited by newlines, with the record values delimited by tabs.

Some questions:


  • What would happen if I queried for a TXT record that contains a tab or newline character?
  • Is it possible to request a different "standard" output? Similar to how the PHP API gives an array (standard), could I request a serialized PHP array, JSON, or XML output instead of what is being given by default? [/LIST] I am using the CLI because our server management tool already has SSH access to the servers, so it is actually easier to call "nodeworx" over SSH rather than managing the nodeworx API key (an additional key). Now if only I could get an output format that is easy to parse remotely (in PHP), I'd be set. If I use the command line, is there a standard format, or should I expect parsing needs to be unique per API call?
    1. Nothing good, though the InterWorx interface won’t allow those records to be created in the first place.

    2. At the moment, no.

    The CLI output was intended to be easy to parse at the command line.

    Unfortunately, it’s not even as cut-and-dry as just tab-delimited, either. The output function delivers what we call a “payload”. If the payload is a string, CLI outputs the string only. If it’s an associative array, it outputs name-value pairs in this format "{$key}: {$value}
    ". A non-associative array is presented as tab-delimited.

    I’ll talk to the guys today - this might be something we want to implement.


    Sounds good! Thanks for considering the feature request.

    I came up with a workaround to suit my needs for now. Basically, I made a wrapper class that uses my SSH connection to call nodeworx with the listApikey command. Once the API key is obtained, I am using it with the PHP API using SOAP as the connection example models. This is a good work-around, but I would still prefer to bypass the extra step/connection if it’s possible later.

    I’ve actually implemented the JSON bit already :slight_smile:

    I’m not sure what release this would get into - we’re due to release 4.5 soon, but we keep pushing it back to cram extra features into it :slight_smile:

    Hey Jimp -

    Just wanted to let you know the JSON output did make it into the 4.5 release, which is out now. Just add “-o json” to the command you’re running.


    I was out on vacation last week, but I wanted to say thanks for your hard work on this! I will be trying it out very soon.