Eventtemplate
Subprocess
Execute shell commands from Jinja2 templates.
The subprocess variable lets you execute shell commands from templates.
| Parameter | Type | Default | Description |
|---|---|---|---|
command | string | — | Shell command to execute. |
cwd | string | None | Working directory. |
env | mapping | None | Environment variables. |
timeout | float | None | Timeout in seconds. |
The run method returns a result object with three fields:
| Field | Type | Description |
|---|---|---|
stdout | string | Standard output (decoded as UTF-8). |
stderr | string | Standard error (decoded as UTF-8). |
exit_code | int | Process exit code. |
{%- set result = subprocess.run('hostname', timeout=5.0) -%}
{{ result.stdout | trim }}Subprocess calls run synchronously and block event production. Use short timeouts to avoid stalling the pipeline.