Skip to main content

exec

Execute shell commands and capture stdout, stderr, and return codes.

Overview

The exec node runs operating system commands from within your EdgeFlow pipeline. It supports both one-shot execution and long-running spawned processes, with configurable timeouts. Cross-platform compatible — uses sh -c on Linux/macOS and cmd /C on Windows.

Shell
Execution
Spawn
Mode
Cross
Platform
Timeout
Control

Properties

Property Type Default Description
command string "" Shell command to execute
appendPayload boolean false Append msg.payload to the command as an argument
useSpawn boolean false Use spawn mode for long-running processes (streams output)
timeout number 10 Maximum execution time in seconds (0 = no limit)
oldrc boolean false Use legacy return code format

Execution Modes

Exec Mode (Default)

Runs command, waits for completion, returns all output at once

command: "uname -a"
// Waits for command to finish
// Output 1: stdout (string)
// Output 2: stderr (string)
// Output 3: return code (number)

Spawn Mode

Streams output line-by-line as the process runs

command: "tail -f /var/log/syslog"
useSpawn: true
// Output streams in real-time
// Each line → separate message
// msg.payload contains each line

Linux / macOS

Commands run via the POSIX shell

// Executed as:
sh -c "your_command_here"

// Pipes and redirects work:
command: "ps aux | grep node"

Windows

Commands run via the Windows command interpreter

// Executed as:
cmd /C "your_command_here"

// Windows commands:
command: "systeminfo"

Example: System Information Gathering

Collect host system details and disk usage for monitoring dashboards.

// Exec node configuration — hostname and OS info
{
  "command": "uname -a",
  "appendPayload": false,
  "useSpawn": false,
  "timeout": 10
}

// Output 1 (stdout):
// "Linux edgeflow-pi 5.15.0 #1 SMP armv7l GNU/Linux"

// Second exec node — disk usage
{
  "command": "df -h --output=target,pcent | tail -n +2",
  "timeout": 10
}

// Output 1 (stdout):
// "/              45%"
// "/boot          12%"
// "/data          78%"

// Chain into a function node to parse and alert if > 80%

Example: GPIO Control via Command Line

Toggle a Raspberry Pi GPIO pin using the command-line sysfs interface.

// Exec node — export and set GPIO pin high
{
  "command": "echo 17 > /sys/class/gpio/export 2>/dev/null; echo out > /sys/class/gpio/gpio17/direction; echo 1 > /sys/class/gpio/gpio17/value",
  "timeout": 5
}

// Exec node — read GPIO pin state
{
  "command": "cat /sys/class/gpio/gpio17/value",
  "timeout": 5
}

// Output 1 (stdout): "1"  (pin is HIGH)

// Use appendPayload to pass dynamic pin numbers:
{
  "command": "echo",
  "appendPayload": true
}
// msg.payload = "1 > /sys/class/gpio/gpio17/value"
// Effectively runs: echo 1 > /sys/class/gpio/gpio17/value

Example: Dynamic Command with Payload

Ping a host address supplied by the incoming message payload.

// Exec node configuration
{
  "command": "ping -c 3",
  "appendPayload": true,
  "timeout": 15
}

// Incoming message
{
  "payload": "192.168.1.1"
}

// Executes: ping -c 3 192.168.1.1
// stdout → "3 packets transmitted, 3 received, 0% packet loss"
// return code → 0 (success)

Common Use Cases

System Monitoring

Collect CPU, memory, disk stats via OS commands

Hardware Control

Toggle GPIO pins, control peripherals via CLI

Script Execution

Run bash or batch scripts as part of a flow

Network Diagnostics

Ping, traceroute, DNS lookups from flows

Related Nodes