Bash
A developer's guide to the Bash action for executing shell commands and scripts.
The Bash Action is a powerful, developer-focused tool that allows you to execute arbitrary shell commands on the AgenticFlow server. This opens up a vast range of possibilities, from file manipulation and system commands to running custom scripts and interacting with command-line tools like curl
, jq
, and git
.
**Security Warning** The Bash action runs commands directly on the server. Be extremely cautious about the commands you run, especially when using dynamic inputs from previous steps. Never execute commands from untrusted sources. Misuse can lead to security vulnerabilities or data loss.
Configuration
Input Parameters
Commands
Text
The shell command or script to execute. You can use variables (e.g., {{llm_action.output}}
) to dynamically insert data into your script.
Output Parameters
stdout
Text
The standard output from the executed command. This is the primary data you'll use in subsequent actions.
stderr
Text
The standard error output. Useful for debugging and error handling.
exitCode
Number
The exit code of the command. 0
typically indicates success, while any other number indicates an error.
Using Variables in Commands
You can pass data from other actions into your Bash commands. For example, to use a filename generated by a previous step:
Example 1: Check if a File Exists
A simple use case is checking for the existence of a file on the server.
Commands:
ls /path/to/my/file.txt
Logic:
If the command succeeds, the
exitCode
will be0
.If the file doesn't exist, the command will fail, and the
exitCode
will be non-zero. You can use a Conditional Action to check{{bash_action.exitCode}}
and branch your workflow accordingly.
Example 2: Using curl
and jq
curl
and jq
A common pattern is to fetch data from an API with curl
and then parse it with jq
, a command-line JSON processor.
Let's say you want to get the current price of Bitcoin.
Commands:
Output:
The
stdout
of this action will be the current Bitcoin price as a string (e.g.,"68,543.21"
). You can then use this value in an LLM action, save it to a sheet, or send it in an email.
Last updated
Was this helpful?