On this page
Sommatic Docs
Open portal

Shell Command

Run a program within the workflow, without a shell.

View as Markdown
Open in
Code Available code.shell Version 2.0.0 Execution: async

Runs one program with a list of arguments, without a shell, on the host that runs the worker, and returns its trimmed stdout and stderr.

The program runs with its arguments as a list: values from upstream nodes are passed as arguments and are never interpreted by a shell, so they cannot inject commands. The process does not inherit the service environment.

Features:

  • Program and arguments as separate fields; each argument supports {{expressions}}.
  • Stdout and stderr captured separately, with a configurable working directory and timeout.

Examples:

  • command ls, args ["-la", "/tmp/uploads"]
  • command base64, args ["--decode", "{{ $json.file }}"]

Pipes, redirections and && are not available: chain nodes, or use code.js / code.python.

How it works

  1. Resolves the config; each element of args can use {{ }} expressions.
  2. Validates command: required, and only a program name or path made of letters, digits and _ . / @ + - (no spaces, quotes, pipes or operators). args must be an array (default []).
  3. Converts every non-string argument to its JSON text.
  4. Runs the program in cwd (default: the working directory of the orchestrator process) with a timeout of execution.timeout, else timeout, else 10000 ms.
  5. Exit code 0 leaves through out with { stdout, stderr } trimmed; a non-zero exit, a timeout or a launch failure leaves through error with the untrimmed output.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-list-uploads",
  "label": "List uploads",
  "operator_slug": "code.shell",
  "operator_version": "2.0.0",
  "config": {
    "command": "ls",
    "args": [
      "-la",
      "{{ $json.folder }}"
    ],
    "cwd": "/tmp",
    "execution": {
      "timeout": 10000
    }
  }
}

Configuration

command string Required

Program name or path (no spaces, pipes or shell operators).

args array<string> Optional

Arguments passed to the program as-is. Each one supports {{expressions}}.

Default: []

cwd string Optional

Directory to run the program in. Defaults to the application root.

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

execution.timeout
Timeout in ms (default 10000). A top-level timeout, not declared in the schema, is used when this is empty. execution.timeout_ms from the generic execution settings is ignored by this node.
args
Each element is passed to the program as one argument, exactly as resolved: no globbing, variable expansion or quoting is applied.

Output ports

out default

The program exited with code 0.

Data
{
  "stdout": "total 16\n-rw-r--r--  1 app  app  18342 Nov 25 14:12 orders.csv",
  "stderr": ""
}
error

Validation failed (data is { error }), or the program exited non-zero, timed out, exceeded the output buffer or could not start (data is { error, stderr, stdout }).

Data
{
  "error": "Command failed: ls -la /tmp/missing\nls: /tmp/missing: No such file or directory\n",
  "stderr": "ls: /tmp/missing: No such file or directory\n",
  "stdout": ""
}

In expressions

What a later node can read from this node's output with $("Shell Command").item.json.<path> (write your node's label instead of Shell Command). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Shell Command").item.json.stdoutstring= "total 16\n-rw-r--r-- 1 app app 18342 Nov …"Standard output from the program.
$("Shell Command").item.json.stderrstring= ""Standard error output from the program.

Errors

Message Port Cause and fix
command must be a program name or path without a shell (no spaces, pipes or operators); pass its arguments in args error command contains spaces or shell syntax, for example ls -la. Put ls in command and ["-la"] in args.
args must be an array error args is a string or object. Write it as a JSON array of strings.
command is required error command is empty or not a string.
spawn <command> ENOENT error The program is not installed or not on the PATH of the host that runs the worker.
Command failed: <command> <args> <stderr> error The program exited non-zero or was stopped by the timeout. Read stderr; raise execution.timeout for long programs.

Input contract

command string Required
args array<string> Optional
cwd string Optional
timeout number Optional

Output contract

stdout string Optional

Standard output from the program.

stderr string Optional

Standard error output from the program.

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "code.shell",
  "name": "Shell Command",
  "category": "code",
  "version": "2.0.0",
  "description": "Run a program within the workflow, without a shell.\n\n  The program runs with its arguments as a list: values from upstream nodes are passed as arguments and are never interpreted by a shell, so they cannot inject commands. The process does not inherit the service environment.\n\n  **Features:**\n  - Program and arguments as separate fields; each argument supports {{expressions}}.\n  - Stdout and stderr captured separately, with a configurable working directory and timeout.\n\n  **Examples:**\n  - command `ls`, args `[\"-la\", \"/tmp/uploads\"]`\n  - command `base64`, args `[\"--decode\", \"{{ $json.file }}\"]`\n\n  Pipes, redirections and `&&` are not available: chain nodes, or use code.js / code.python.",
  "capabilities": [
    "shell",
    "process",
    "terminal",
    "script"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "command": {
        "type": "string",
        "title": "Program",
        "description": "Program name or path (no spaces, pipes or shell operators)."
      },
      "args": {
        "type": "array",
        "title": "Arguments",
        "description": "Arguments passed to the program as-is. Each one supports {{expressions}}.",
        "items": {
          "type": "string"
        },
        "default": []
      },
      "cwd": {
        "type": "string",
        "title": "Working Directory",
        "description": "Directory to run the program in. Defaults to the application root."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "timeout": {
            "type": "number",
            "default": 10000,
            "title": "Timeout (ms)",
            "description": "Maximum time to wait for the program to finish."
          },
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    },
    "required": [
      "command"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "command": {
        "type": "string"
      },
      "args": {
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "cwd": {
        "type": "string"
      },
      "timeout": {
        "type": "number"
      }
    },
    "required": [
      "command"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "stdout": {
        "type": "string",
        "description": "Standard output from the program."
      },
      "stderr": {
        "type": "string",
        "description": "Standard error output from the program."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Output",
      "description": "Program exited with code 0.",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Program returned a non-zero exit code, could not start or timed out.",
      "is_default": false,
      "supports_condition": true
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "desktop-agent",
    "local-agent"
  ],
  "tags": [
    "shell",
    "bash",
    "terminal",
    "script",
    "code"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Retries (retryOnFail)
No
Capabilities
shellprocessterminalscript
Tags
shellbashterminalscriptcode

Notes and limits

  • Pipes, redirections and && are not available; chain nodes or use code.js or code.python instead.
  • The program receives only locale, path and proxy environment variables. Output above about 1 MB on stdout or stderr makes the run fail. The exit code is not included in the output.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs