← All procedures
shell.exec
Execute command string via shell
CLI- Package
- @procedures/shell · README
- Path
["shell","exec"]- CLI
mark shell exec --command <string>- As data
{"$proc":["shell","exec"],"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","exec"], { command: "<command>" });
console.log(JSON.stringify(result));From the command line
$ mark shell exec --command <string>
As data, in a program
{ "$proc": ["shell", "exec"], "input": { "command": "<command>" } }Input
| Field | Type | Required | Default | Description |
|---|
command | string | yes | | Full command string to execute via shell |
cwd | string | no | | Working directory |
env | object | no | | Environment variables |
timeout | number | no | | Timeout in milliseconds. At the timeout, the shell and the programs that it started are killed. |
shell | boolean | string | no | true | Shell to use: a path, or `true` for the system shell (`cmd.exe` or `/bin/sh`). `false` is the same as `true`. |
maxBuffer | number | no | | The most bytes kept of each output stream (default: 64 MiB). The procedure drops the rest. |
stdin | string | no | | Text to write to stdin. Without it, stdin is empty. |
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": "Full command string to execute via shell"
},
"cwd": {
"description": "Working directory",
"type": "string"
},
"env": {
"description": "Environment variables",
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "string"
}
},
"timeout": {
"description": "Timeout in milliseconds. At the timeout, the shell and the programs that it started are killed.",
"type": "number"
},
"shell": {
"default": true,
"description": "Shell to use: a path, or `true` for the system shell (`cmd.exe` or `/bin/sh`). `false` is the same as `true`.",
"type": [
"boolean",
"string"
]
},
"maxBuffer": {
"description": "The most bytes kept of each output stream (default: 64 MiB). The procedure drops the rest.",
"type": "number"
},
"stdin": {
"description": "Text to write to stdin. Without it, stdin is empty.",
"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": {}
}
}