Skip to content

Script Development / DataFlux Func Sidecar

Using the Sidecar Connector operation object allows users to invoke Sidecar to execute Shell commands.

DFF.CONN(...) parameters are as follows:

Parameter Type Required / Default Description
connector_id str Required Connector ID

For the complete documentation on Sidecar, please refer to the 'Sidecar Guide'

.shell(...)

Invokes Sidecar to execute a Shell command, parameters are as follows:

Parameter Type Required / Default Description
cmd str Required The Shell command to execute
Example: "ls -l"
wait bool True Whether to wait for the execution to complete
When set to False, this function will return immediately and will not return the terminal output
workdir str None The working directory for the Shell command execution
Example: "/home/dev"
envs dict None Environment variables, both keys and values are strings
Example: {"MY_NAME": "Tom"}
callback_url str None Callback URL, after the command is executed, stdout and stderr will be sent to the specified URL using POST
Generally used with the wait=False parameter to achieve asynchronous callback
timeout int 3 Request timeout
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(...) and specifying the callback_url parameter, Sidecar will send the standard output stdout and standard error stderr to this address via POST after executing the Shell command.

The specific structure is as follows:

Text Only
1
2
3
4
5
6
7
8
9
POST {callback_url}
Content-Type: application/json

{
    "kwargs": {
        "stdout": "<Standard Output Text>",
        "stderr": "<Standard Error Text>"
    }
}

This structure matches DataFlux Func's 'Sync API (Legacy: Auth Link) Standard POST Method' , and can directly use the 'Sync API (Legacy: Auth Link)' to receive the post-execution callback