Script Development / DataFlux Func Sidecar
Using the Sidecar connector operation object allows users to invoke Sidecar to execute Shell commands.
The parameters for DFF.CONN(...) are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
connector_id |
str | Required | Connector ID |
For the complete usage documentation of Sidecar, please refer to the 'Sidecar Manual'
.shell(...)
Invokes Sidecar to execute a Shell command. The parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
cmd |
str | Required | The Shell command to execute e.g., "ls -l" |
wait |
bool | True |
Whether to wait for execution to complete When set to False, this function returns immediately and will not return the terminal output. |
workdir |
str | None |
The working directory for the Shell command execution e.g., "/home/dev" |
envs |
dict | None |
Environment variables, both keys and values are strings e.g., {"MY_NAME": "Tom"} |
callback_url |
str | None |
Callback URL. After the command executes, stdout and stderr will be sent to the specified URL via POST.Typically used with the wait=False parameter for asynchronous callbacks. |
timeout |
int | 3 |
Request timeout (in seconds) Note: This parameter is not the timeout for the Shell command, but the timeout for the Func request to Sidecar. Meaning the Func request to Sidecar may timeout, but the executed Shell command will not stop. |
Post-execution Callback
After calling SidecarHelper.shell(...) with the callback_url parameter specified, Sidecar will send the standard output stdout and standard error stderr to this address via POST after the Shell command finishes execution.
The specific structure is as follows:
| Text Only | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
This structure matches the standard POST method of DataFlux Func's 'Function API' and can be directly used with the 'Function API' to receive the post-execution callback.