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.

Configuration

Input Parameters

Parameter
Type
Description

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

Parameter
Type
Description

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 command in the Bash Action
# This will list details for the specific file
ls -la "{{previous_action.filename}}"

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 be 0.

    • 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

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:

    # Fetch data from the CoinDesk API and extract the USD price
    curl -s https://api.coindesk.com/v1/bpi/currentprice.json | jq -r '.bpi.USD.rate'
  • 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?