Execute Commander icon

Execute Commander

Execute shell commands on the host using child_process

Execute Commander

AI-generated

Overview

This node executes shell commands on the host machine using Node.js child process capabilities. It supports running a command once for all input items or individually per item, and offers two execution modes: one that captures the entire output at once (suitable for short commands) and another that streams output continuously (better for long-running or verbose commands).

Common scenarios include:

  • Running quick system checks or scripts and capturing their output.
  • Executing batch commands once to affect multiple data items.
  • Streaming logs or outputs from long-running processes.
  • Automating shell-based tasks within an n8n workflow.

Example use cases:

  • Running echo "Hello, n8n!" to generate a simple message.
  • Executing a script that processes files and returns results.
  • Launching a monitoring command that streams status updates.

Properties

Name Meaning
Execution Once Whether to execute the command once for all input items (true) or separately for each item (false).
Hidden Window On Windows only: whether to hide the command window during execution (true hides it).
Execution Mode Choose between:
- Exec: runs command capturing full output (good for short commands).
- Spawn: runs command streaming output live (good for long-running commands).
Command The shell command string to execute. Required. Example: echo "Hello, n8n!".

Output

The node outputs an array of JSON objects, one per executed command (either once for all items or per item):

Each output JSON contains:

  • stdout: The standard output text from the command execution.
  • stderr: The standard error text from the command execution.
  • command: The exact command string that was run.

If an error occurs during execution and the node is set to continue on failure, the output JSON will contain:

  • error: The error message describing what went wrong.

No binary data output is produced by this node.

Dependencies

  • Requires Node.js built-in modules child_process and util.
  • No external API keys or services are needed.
  • Runs commands on the host environment where n8n is installed; thus, permissions and environment availability of commands matter.
  • On Windows, the option to hide the command window is supported.

Troubleshooting

  • Command exited with code X: Indicates the shell command returned a non-zero exit code, meaning failure or error in the command itself. Check the command syntax and environment.
  • Command execution failed: [message]: General failure in running the command, possibly due to invalid command, missing executable, or permission issues.
  • If using spawn mode, ensure the command and its arguments are correctly split and valid.
  • When running once for all items, errors affect all outputs; when running per item, errors are isolated per item.
  • On Windows, if the command window does not appear but no output is received, try disabling the hidden window option.
  • Ensure the command is available in the system PATH or provide absolute paths.

Links and References

Discussion