← 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

FieldTypeRequiredDefaultDescription
commandstringyesCommand to run
argsstring[]no[]Arguments to pass
cwdstringnoWorking directory
envobjectnoEnvironment variables to set
timeoutnumbernoTimeout in milliseconds
encodingstringno"utf8"Encoding for output (default: utf8)

Output

FieldTypeRequiredDefaultDescription
exitCodenumberyesThe exit code (0 is success, -1 when a signal ended the program)
stdoutstringyesThe standard output
stderrstringyesThe standard error
successbooleanyesTrue when the exit code is 0
durationnumberyesThe time of the command, in milliseconds
signalstringnoThe 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": {}
  }
}