XML-RPC Protocol Method: consolecommand

From Dreamwidth Notes
Revision as of 17:56, 19 September 2010 by Murklins (Talk | contribs)

Jump to: navigation, search
Needs Update: This documentation was ported over from LJ's Server Manual with minimal modification. It may not match Dreamwidth's implementation of the method, and needs to be double checked against the DW code and updated as necessary.

The Dreamwidth server has a text-based shell-like administration console where less-often used commands can be entered. There's a web interface to this shell online, and this is another gateway to that.

Inputs

username Scalar. Required. Username of user logging in.

auth_method Scalar. Optional. Authentication method used for this request. The default value is "clear", for plain-text authentication. "cookie" and any of the challenge-response methods are also acceptable.

password Deprecated. Scalar. Optional. Password of user logging in in plaintext. If using the "clear" authentication method, either this or "hpassword" must be present.

hpassword Deprecated. Scalar. Optional. MD5 digest of user's password. Not much more secure than password, but at least it's not in plain text.

auth_challenge Scalar. Optional. If using challenge-response authentication, this should be the challenge that was issued to you by the server.

auth_response Scalar. Optional. If using challenge-response authentication, this should be the response hash that you generate, based on the formula required for your challenge.

ver Scalar. Optional. Protocol version supported by the client; assumed to be 0 if not specified. See Protocol Versions for details on the protocol version.

commands Array of strings. Required. Array of commands to send, with double quotes around any arguments with spaces, and double quotes escaped by backslashes, and backslashes escaped with backslashes. Optionally, you can send a listref instead of a string for this argument, in which case, we'll use your argument separation and not parse it ourselves.

Example Request

<?xml version="1.0"?>
<methodCall>
  <methodName>LJ.XMLRPC.consolecommand</methodName>
  <params>
    <param>
      <value><struct>
        <member>
          <name>username</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>password</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>ver</name>
          <value><int>1</int></value>
        </member>
        <member>
          <name>commands</name>
          <value><array><data>
            <value><string>help print</string></value>
          </data></array></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodCall>

Outputs

results Array of structs. One struct returned for each command run, that struct containing both the overall return value, and the line-by-line output of the command, with each line of output being tagged by type (think stdout vs. stderr, but with stdinfo also). The web interface shows errors in red, normal output in black, and informational output in green. Clients are encouraged to also, if possible. Each struct contains these keys:

  • success Int. Return status of nth command. 0 or 1.
  • output Array of arrays. This array holds a 2-item array for each line of a command's output. The items in the array are:
    • String. Type of output line. Either "" (normal output), "error", or "info", something to be emphasized over normal output.
    • String. The text of that line.

Example Response

HTTP/1.1 200 OK
Connection: close
Content-length: 1189
Content-Type: text/xml
Date: Tue, 16 Jul 2002 22:59:33 GMT
Server: Apache/1.3.4 (Unix)
 
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value><struct>
        <member>
          <name>results</name>
          <value><array><data>
            <value><struct>
              <member>
                <name>success</name>
                <value><int>1</int></value>
              </member>
              <member>
                <name>output</name>
                <value><array><data>
                  <value><array><data>
                    <value><string></string></value>
                    <value><string>print ...</string></value>
                  </data></array></value>
                  <value><array><data>
                    <value><string></string></value>
                    <value><string>  This is a debugging function.  Given an arbitrary number of</string></value>
                  </data></array></value>
                  <value><array><data>
                    <value><string></string></value>
                    <value><string>  meaningless arguments, it'll print each one back to you.  If an</string></value>
                  </data></array></value>
                  <value><array><data>
                    <value><string></string></value>
                    <value><string>  argument begins with a bang (!) then it'll be printed to the error</string></value>
                  </data></array></value>
                  <value><array><data>
                    <value><string></string></value>
                    <value><string>  stream instead.</string></value>
                  </data></array></value>
                </data></array></value>
              </member>
            </struct></value>
          </data></array></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodResponse>