Skip to main content

Bash Output

Retrieves output from a running or completed background bash shell.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Shell ID - string - The ID of the background shell to retrieve output from (required).
  • Filter - string - Optional regex pattern to filter output lines (optional).

Outputs

  • New Stdout - string - New standard output since last check.
  • New Stderr - string - New standard error since last check.
  • Status - string - Current shell status: running, completed, or failed.
  • Exit Code - int - Exit code if shell has completed (0 = success).
  • Shell Info - object - Detailed shell information:
    • shellID - The shell ID
    • command - Original command
    • status - Current status
    • exitCode - Exit code (if completed)
    • totalOutputLines - Total lines of stdout captured
    • totalErrorLines - Total lines of stderr captured
    • newOutputLines - Lines of stdout returned this call
    • newErrorLines - Lines of stderr returned this call

How It Works

The Bash Output node retrieves output from background shells started by the Shell node. When executed, the node:

  1. Validates the shell ID is provided
  2. Looks up the background shell in the registry
  3. Retrieves new output since the last read:
    • Tracks read position for stdout
    • Tracks read position for stderr
    • Returns only new lines since last call
  4. Applies optional regex filter to output lines
  5. Returns new output, status, and metadata
  6. Updates read positions for next call

Requirements

  • Valid shell ID from a Shell node background execution
  • Background shell must exist in the registry

Error Handling

The node will return specific errors in the following cases:

  • Missing shell ID - "Shell ID is required"
  • Empty shell ID - "Shell ID cannot be empty"
  • Shell not found - "No background shell found with ID: {{shellID}}"
  • Invalid filter - "Invalid filter regex: {{error}}"

Usage Examples

Basic Output Retrieval

Shell ID: abc123-xyz789

Filtered Output

Shell ID: abc123-xyz789
Filter: ERROR|WARNING

Continuous Monitoring

Use in a loop to monitor long-running processes:

1. Shell node (background): python long_process.py
2. Loop:
- Delay 5 seconds
- Bash Output: retrieve new output
- Check status
- If status = completed, break

Error Detection

Shell ID: abc123-xyz789
Filter: ^ERROR:

Usage Notes

  • Each call returns only NEW output since the last call
  • The node maintains separate read positions for stdout and stderr
  • Filter regex is applied to individual lines
  • Empty result means no new output since last check
  • Status values: "running", "completed", "failed"
  • Exit code is only meaningful when status is "completed" or "failed"
  • The shell must be started with "Run in Background: true" in the Shell node
  • Output is line-buffered - complete lines are returned
  • Very long lines may be split

Status Values

  • running - Process is still executing
  • completed - Process finished successfully (exit code 0)
  • failed - Process finished with error (non-zero exit code)

Output Tracking

The node tracks what has been read:

  • First call: Returns all output since process started
  • Second call: Returns only new output since first call
  • Third call: Returns only new output since second call
  • And so on...

This allows you to:

  • Monitor progress in real-time
  • Avoid processing the same output twice
  • Track incremental changes

Common Use Cases

Long-Running Process Monitoring

Monitor build processes, data processing, or batch jobs.

Log Streaming

Stream logs from background services in real-time.

Error Detection

Watch for errors or warnings in running processes.

Progress Tracking

Monitor progress messages from long-running scripts.

Test Execution

Watch test output as tests run in the background.

Deployment Monitoring

Track deployment script output and status.

Best Practices

  • Poll regularly for running processes (e.g., every 5-10 seconds)
  • Check status to know when process completes
  • Use filters to focus on important output (errors, warnings)
  • Handle both stdout and stderr - important messages may be in either
  • Check exit code when status is completed/failed
  • Clean up completed processes with Kill Bash
  • Store Shell ID in a variable for repeated checks
  • Implement timeout logic for processes that may hang
  • Log output for debugging and audit trails

Example Workflow

Complete Background Process Flow

1. Shell Node (Background)
- Command: npm run build
- Run in Background: true
- Output: shell_id

2. Loop (while status != "completed" and != "failed")
- Delay: 5 seconds
- Bash Output:
- Shell ID: `{{shell_id}}`
- Output: new_stdout, new_stderr, status
- Log Output:
- Log: `{{new_stdout}}` `{{new_stderr}}`
- Check Status:
- If status = "completed": break
- If status = "failed": handle error

3. Bash Output (Final)
- Shell ID: `{{shell_id}}`
- Get any remaining output

4. Kill Bash (Cleanup)
- Shell ID: `{{shell_id}}`

Filter Examples

Filter Errors Only

Filter: ^ERROR

Filter Warnings and Errors

Filter: (ERROR|WARNING|FATAL)

Filter Progress Updates

Filter: Progress:|Complete:|\d+%

Filter Specific Keywords

Filter: (success|failed|completed)

Comparison with Other Nodes

  • Bash Output vs Shell: Bash Output reads from background shells; Shell executes commands
  • Bash Output vs Kill Bash: Bash Output reads output; Kill Bash terminates processes
  • Bash Output vs Read: Bash Output reads process output; Read reads files