Device Commands

📘

This page is a work in progress

This group of REST API allows running system commands directly on the device.

For more informations about Commands, please read System Management

Execute a Command

The following API will execute commands on a (currently connected) remote device.

POST /{scopeId}/devices/{deviceId}/commands/_execute

The required path parameters to be used with this call are:

  • {scopeId} is the scopeId of the tenant (account) to which the desired device belongs and can be retrieved from the response of the authentication call; the "_" character can be used for indicating the scopeId of the user currently authenticated with the token;
  • {deviceId} is the id of the desired device.

It is also possible to add the optional timeout query parameter, an integer value which represents the timeout for the request in milliseconds.

Body

This call have a required body parameter that defines an object containing the commands to execute on the remote device. As an example:

{
  "command": "ls",
  "arguments": {
    "argument": "-lisa"
  },
  "timeout": 60000
}

In case of multiple arguments, the arguments property will be an array of strings:

{
  "command": "ls",
  "arguments": {
    "argument": [
        "-l",
        "-i",
        "-s",
        "-a"
      ]
    }
  "timeout": 60000
}

It is also possible to send a script to be executed remotely. The body attribute of the body parameter can be used for this purpose by passing the content of the script file, encoded in base64 format.

Response

The response of this call will contain the output of the command executed on the remote device. For instance:

{
  "type": "deviceCommandOutput",
  "stderr": "",
  "stdout": "total 40\n12503707 4 drwxrwxrwt 1 root root 4096 Sep 13 07:44 .\n12507178 4 drwxr-xr-x 1 root root 4096 Sep 12 08:03 ..\n61409843 4 drwxrwxrwt 2 root root 4096 Feb 28  2018 .ICE-unix\n61409845 4 drwxrwxrwt 2 root root 4096 Feb 28  2018 .Test-unix\n61409838 4 drwxrwxrwt 2 root root 4096 Feb 28  2018 .X11-unix\n61409844 4 drwxrwxrwt 2 root root 4096 Feb 28  2018 .XIM-unix\n61409846 4 drwxrwxrwt 2 root root 4096 Feb 28  2018 .font-unix\n12503708 4 drwxr-xr-x 3 root root 4096 Sep 12 08:03 .kura\n12507353 4 drwxr-xr-x 2 root root 4096 Sep 12 08:03 hsperfdata_root\n12507385 4 drwxr-xr-x 3 root root 4096 Sep 12 08:03 kura\n",
  "exitCode": 0,
  "hasTimedout": false
}