All Products
Search
Document Center

Simple Application Server:RunCommand

Last Updated:Oct 30, 2024

Runs commands on a simple application server.

Operation description

Command Assistant is an automated O&M tool for Simple Application Server. You can maintain simple application servers by running shell, PowerShell, and batch commands in the Simple Application Server console without remotely logging on to the servers.

Before you use Command Assistant, take note of the following items:

  • The simple application server must be in the Running state.
  • The Cloud Assistant client is installed on the server. By default, the Cloud Assistant client is installed on simple application servers. If you have manually uninstalled the client, you must reinstall it. For more information, see Install the Cloud Assistant Agent.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
swas-open:RunCommandcreate
  • Command
    acs:swas-open:{#regionId}:{#accountId}:{#CommandId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
CommandContentstringYes

The content of the command. Take note of the following items:

  • If you set EnableParameter to true, the custom parameter feature is enabled in the command content and you can configure custom parameters based on the following rules:
  • Define custom parameters in the {{}} format. Within {{}}, the spaces and line feeds before and after the parameter names are ignored.
  • The number of custom parameters cannot be greater than 20.
  • A custom parameter name can contain only letters, digits, underscores (_), and hyphens (-). The name is case-insensitive.
  • Each custom parameter name cannot exceed 64 bytes in length.
ifconfig -s
WorkingDirstringNo

The execution path of the command. Custom paths are supported. Default execution paths vary based on the operating systems of the servers.

  • For Linux servers, the default path is /root of the root user.
  • For Windows servers, the default path is C:\Windows\system32.
/home/
RegionIdstringYes

The region ID of the simple application server. You can call the ListRegions operation to query the most recent region list.

cn-hangzhou
TimeoutintegerNo

The timeout period of the command on the server.

If a command execution task times out, Command Assistant forcibly terminates the task process. Valid values: 10 to 86400. Unit: seconds. The period of 86400 seconds is equal to 24 hours.

Default value: 60.

60
TypestringYes

The language type of the command. Valid values:

  • RunBatScript: batch commands (applicable to Windows servers).
  • RunPowerShellScript: PowerShell commands (applicable to Windows servers).
  • RunShellScript: shell commands (applicable to Linux servers).
RunShellScript
EnableParameterbooleanNo

Specifies whether to enable the custom parameter feature.

Default value: false.

false
ParametersobjectNo

The custom parameters in the key-value pair format that are to be passed in when the command includes custom parameters. For example, if the command content is echo {{name}}, you can use Parameters to pass in the {"name":"Jack"} key-value pair. The name key of the custom parameter is automatically replaced with the paired Jack value to generate a new command. As a result, the echo Jack command is executed.

Number of custom parameters ranges from 0 to 20. Take note of the following items:

  • The key cannot be an empty string. It can be up to 64 characters in length.
  • The value can be an empty string.
  • After custom parameters and original command content are encoded in Base64, the command cannot exceed 16 KB in size.
  • The custom parameter names that are specified by Parameters must be included in the custom parameter names that you specified when you created the command. You can use empty strings to represent the parameters that are not passed in.

This parameter is empty by default, which indicates to disable the custom parameter feature.

{"name":"Jack", "accessKey":"LTAIdyvdIqaRY****"}
WorkingUserstringNo

A user of the server who runs the command. We recommend that you run the command as a regular user to reduce security risks. Default values:

  • For Linux servers, the default value is root.
  • For Windows servers, the default value is system.
root
WindowsPasswordNamestringNo

The name of the password to be used to run the command on a Windows server.

If you want to use a username other than the default "system" username to run the command on a Windows server, you must specify both the WindowsPasswordName and WorkingUser parameters. To mitigate the risk of password leaks, the password is stored in plaintext in Operation Orchestration Service (OOS) Parameter Store, and only the name of the password is passed in by using WindowsPasswordName.

axtSecretPassword
InstanceIdstringYes

The ID of the simple application server.

ace0706b2ac4454d984295a94213****
NamestringYes

The name of the command.

testName

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****
InvokeIdstring

The execution ID.

t-hz02p9545t6****

Examples

Sample success responses

JSONformat

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "InvokeId": "t-hz02p9545t6****"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history