You need to enable JavaScript to run this app.
文档中心
云服务器

云服务器

复制全文
下载 pdf
云助手
ModifyCommand - 修改自定义命令
复制全文
下载 pdf
ModifyCommand - 修改自定义命令
调用ModifyCommand接口,修改指定自定义命令内容。​
使用说明​
  • 命令执行期间也允许修改,修改命令后,后续执行会按照新的命令内容执行。​
  • 可通过ParameterDefinitions.N.xxx参数在命令中配置自定义参数,使用规则如下:​
  • 参数 - N:表示自定义参数的序号,取值范围:1~60。​
  • 多个自定义参数之间用&分隔。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:ModifyCommand​
要执行的操作,取值:ModifyCommand。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
CommandId string 必选 示例值:cmd-hz0127****​
自定义命令ID。可通过DescribeCommands接口查询获取。​
​
Name string 可选 示例值:UpdateAgent​
命令名称。默认空,表示保持原有名称不变。​
  • 字符长度1~32。​
  • 不限制特殊字符。​
​
Type string 可选 示例值:Shell​
命令类型。取值支持:​
  • Shell:表示脚本类型为Shell。​
  • Python:表示脚本类型为Python。​
  • Bat:表示创建一个Bat脚本。​
  • PowerShell:表示创建一个PowerShell脚本。​
​
Description string 可选 示例值:This is description.​
命令描述,默认为空,表示保持原有描述不变。​
  • 字符长度0~256。​
  • 不限制特殊字符。​
​
EnableParameter boolean 可选 示例值:false​
创建的命令是否使用自定义参数。取值:​
  • false:表示不使用自定义参数。​
  • true:表示使用自定义参数。​
​
ContentEncoding string 可选 示例值:Base64​
命令内容是否经过Base64编码处理。取值:​
  • Base64(默认):经过Base64编码处理。​
  • PlainText: 未进行编码处理。​
​
ParameterDefinitions.N.Name string[] 可选 示例值:ParameterDefinitions.1.Name=dir​
参数名称,需要在脚本中通过{{Param}}定义 。命名规则:​
  • 单个参数名不能超过64字节。​
  • 遵循Shell变量命名规则,a-zA-Z0-9-_的组合。首个字符不能以数字开头。中间不能有空格,可以使用下划线。​
​
ParameterDefinitions.N.Type string[] 可选 示例值:String​
参数类型。取值:​
  • String:表示自定义参数类型为String(字符串)类型。​
  • Digit:表示自定义参数类型为Digit(数值)类型。​
​
ParameterDefinitions.N.Required boolean[] 可选 示例值:ParameterDefinitions.1.Required=true​
是否必填。取值:​
  • true:必填。​
  • false:非必填。​
说明​
必填时,使用InvokeCommand接口执行命令,需在其Parameters参数中传入自定义参数值。​
​
ParameterDefinitions.N.DefaultValue string[] 可选 示例值:ParameterDefinitions.1.DefaultValue=ecs​
自定义参数默认值。​
说明​
请根据Type参数指定的参数类型,填写相应类型的默认值。​
​
ParameterDefinitions.N.MinLength integer[] 可选 示例值:ParameterDefinitions.1.MinLength=1​
自定义参数值(字符串)的最小长度。​
  • MinLength取值范围:1~1000。​
  • Type=String时必填,且Required参数为true时默认为1。​
  • 本参数值需小于MaxLength。​
​
ParameterDefinitions.N.MaxLength integer[] 可选 示例值:ParameterDefinitions.1.MaxLength=98​
自定义参数值(字符串)的最大长度。​
  • MaxLength取值范围:1~1000。​
  • Type=String时必填,且Required参数为true时默认为1000。​
  • 本参数值需大于MinLength。​
​
ParameterDefinitions.N.MinValue string[] 可选 示例值:ParameterDefinitions.1.MinValue=1​
自定义参数值(数值)的最小值。​
  • MinValue取值范围:-1000000~1000000。​
  • Type=Digit时必填,且Required参数为true时默认为-1000000。​
  • 本参数值需小于MaxValue。​
​
ParameterDefinitions.N.MaxValue string[] 可选 示例值:ParameterDefinitions.1.MaxValue=100​
自定义参数值(数值)的最大值。​
  • MaxValue取值范围:-1000000~1000000。​
  • Type=Digit时必填,且Required参数为true时默认为1000000。​
  • 本参数值需小于MinValue。​
​
ParameterDefinitions.N.DecimalPrecision integer[] 可选 示例值:ParameterDefinitions.1.DecimalPrecision=4​
自定义参数值(数值)允许的小数点后位数。​
  • DecimalPrecision取值范围:0~10。​
  • Type=Digit时必填,且Required参数为true时默认为0。​
​
CommandContent string 可选 示例值:IyEvYmluL2Jhc2gKZWNobyAib3BlcmF0aW9uIHN1Y2Nlc3MhIg==​
将命令内容进行Base64编码得到的内容。​
说明​
  • 请根据ContentEncoding参数传入相应命令内容。​
  • 请确保编码前的脚本,首行指定了脚本解释器。规则如下:​
  • Shell脚本:首行需为#!/bin/bash。​
  • Python脚本:首行需为#!/usr/bin/python。​
  • 命令内容不能超过16KB。​
  • EnableParameter=true时,命令内容支持使用自定义参数。规则如下:​
  • 自定义参数用{{}}包含的方式定义。​
  • 在{{}}内参数名前后的空格以及换行符会被忽略。​
​
WorkingDir string 可选 示例值:/home​
创建的命令在ECS实例中运行的目录。​
说明​
Linux实例默认路径为/home。​
​
Username string 可选 示例值:root​
执行命令时的用户名。​
说明​
Linux实例默认执行用户为root。​
​
Timeout integer 可选 示例值:60​
创建的命令在ECS实例中执行时最大的超时时间,单位为s(秒)。​
  • 取值范围:30~86400。​
  • 默认值:60。​
说明​
当因为某种原因无法运行创建的命令时,会出现超时现象。超时后,会强制终止命令进程。​
​
​
​
返回参数​
下方仅列出本接口特有的返回参数。更多信息请参见返回结构。​
CommandId string 示例值:cmd-hz0127****​
自定义命令ID。​
​
​
​
请求示例​
​
GET /?Action= ModifyCommand&Version=2020-04-01&CommandId=cmd-ydckta****&Name=demo&CommandContent=IyEvYmluL2Jhc2gKZWNobyB7e2F9fQ==&WorkingDir=/home&Username=root&Timeout=120​
Host: ecs.cn-beijing.volcengineapi.com​
Region: cn-beijing​
Service: ecs​
​
返回示例​
​
{​
"ResponseMetadata":{​
"RequestId":"2023082515303301022514515207C4****",​
"Action":"ModifyCommand",​
"Version":"2020-04-01",​
"Service":"ecs",​
"Region":"cn-beijing"​
},​
"Result":{​
"CommandId":"cmd-ydckta****"​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
LimitExceeded.MaximumName​
The specified Name exceeds the limit.​
指定的命令名称长度超出限制。​
400​
LimitExceeded.MaximumCommandContent​
The specified CommandContent exceeds the limit.​
指定的命令内容长度超出限制。​
400​
InvalidBase64Content.Malformed​
The specified Base64 Content is malformed.​
指定的Base64内容不合法。​
400​
InvalidType.Malformed​
The specified Type is malformed.​
指定的命令类型不合法。​
400​
MissingParameter.CommandId​
The required parameter CommandId is not supplied.​
命令 ID 不能为空。​
400​
LimitExceeded.MaximumTimeout​
The specified timeout exceeds the limit.​
指定的超时时间(s)超出限制。​
400​
LimitExceeded.MaximumDescription​
The specified Description exceeds the limit.​
指定的命令描述长度超出限制。​
400​
MissingParameter.AccountId​
The required parameter AccountId is not supplied.​
用户ID不能为空。​
400​
InvalidEnableParameter.Malformed​
The specified EnableParameter is malformed.​
指定的是否启用参数不合法。​
400​
LimitExceeded.MaximumParameterDefinitions​
The specified ParameterDefinitions exceeds the limit.​
指定的自定义参数定义个数超出限制。​
400​
InvalidParameterDefinitionName.Malformed​
The specified ParameterDefinition Name is malformed. The name can contain only lowercase letters (a to z), uppercase letters (A to Z), numbers (0 to 9), and underscores (_).​
自定义参数名格式错误:仅支持a-zA-Z0-9_的组合,首个字符不能以数字开头。​
400​
MissingParameter.ParameterDefinitionName​
The required parameter ParameterDefinitionName is not supplied.​
自定义参数名不能为空。​
400​
LimitExceeded.MaximumParameterDefinitionName​
The specified ParameterDefinitionName exceeds the limit.​
指定的自定义参数名长度超出限制。​
400​
InvalidParameterDefinitionType.Malformed​
The specified ParameterDefinition Type is malformed.​
自定义参数类型不合法。​
400​
InvalidParameterDefinitions.Malformed​
The specified ParameterDefinitions is malformed.​
指定的参数定义不合法。​
404​
InvalidCommand.NotFound​
The specified Command does not exist.​
指定的命令不存在。​
404​
InvalidParameterDefinitions.NotFound​
The specified ParameterDefinitions does not exist.​
指定的自定义参数未定义。​
409​
InvalidParameterDefinitions.Conflict​
The specified ParameterDefinition already exists.​
指定的自定义参数已存在。​
500​
InternalError​
An internal error has occurred.​
内部错误,请重试。如果多次尝试失败,请提交工单。​
​
​
最近更新时间:2026.01.08 17:57:05
这个页面对您有帮助吗?
有用
有用
无用
无用