← All procedures
shell.run
Run a command with arguments
CLI- Package
- @procedures/shell · README
- Path
["shell","run"]- CLI
mark shell run --command <string>- As data
{"$proc":["shell","run"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/shell"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["shell","run"], { command: "<command>" });
console.log(JSON.stringify(result));From the command line
$ mark shell run --command <string>
As data, in a program
{ "$proc": ["shell", "run"], "input": { "command": "<command>" } }Input
| Field | Type | Required | Default | Description |
|---|
command | string | yes | | Command to run |
args | string[] | no | [] | Arguments to pass |
cwd | string | no | | Working directory |
env | object | no | | Environment variables to set |
timeout | number | no | | Timeout in milliseconds |
encoding | string | no | "utf8" | Encoding for output (default: utf8) |
Output
| Field | Type | Required | Default | Description |
|---|
exitCode | number | yes | | The exit code (0 is success, -1 when a signal ended the program) |
stdout | string | yes | | The standard output |
stderr | string | yes | | The standard error |
success | boolean | yes | | True when the exit code is 0 |
duration | number | yes | | The time of the command, in milliseconds |
signal | string | no | | The signal that ended the program (for example at the timeout) |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Command to run"
},
"args": {
"default": [],
"description": "Arguments to pass",
"type": "array",
"items": {
"type": "string"
}
},
"cwd": {
"description": "Working directory",
"type": "string"
},
"env": {
"description": "Environment variables to set",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "string"
}
},
"timeout": {
"description": "Timeout in milliseconds",
"type": "number"
},
"encoding": {
"default": "utf8",
"description": "Encoding for output (default: utf8)",
"type": "string"
}
},
"required": [
"command"
]
},
"output": {
"type": "object",
"properties": {
"exitCode": {
"type": "number",
"description": "The exit code (0 is success, -1 when a signal ended the program)"
},
"stdout": {
"type": "string",
"description": "The standard output"
},
"stderr": {
"type": "string",
"description": "The standard error"
},
"success": {
"type": "boolean",
"description": "True when the exit code is 0"
},
"duration": {
"type": "number",
"description": "The time of the command, in milliseconds"
},
"signal": {
"description": "The signal that ended the program (for example at the timeout)",
"type": "string"
}
},
"required": [
"exitCode",
"stdout",
"stderr",
"success",
"duration"
],
"additionalProperties": {}
}
}