Skip to main content

Shell Action

Run an inline script directly in an automation pipeline without referencing a saved script.

Updated this week

Introduction

Run a script inline as part of an automation β€” no saved script required. Shell is the right choice for one-off commands or lightweight logic that doesn't need to live in your script library.

For scripts you plan to reuse across multiple automations, see the Run Script action instead.


Configuring the Shell Action

From the automation pipeline in edit mode, click + and select Shell from the System category.

Shell Action

The action panel opens with the script configuration fields.

Shell Action Configuration

Language

Select the scripting language for this script.

Supported languages: Ansible, Bash, Go, osquery, PowerShell, Python, Zsh.

Languages

Timeout (in seconds)

How long Level waits for the script to complete before marking it as failed. Default is 100 seconds.

Run as

The account context the script runs under.

Option

Behavior

Local system

Runs as the SYSTEM account β€” elevated, no user context

Current user

Runs as the currently logged-in user β€” useful for user-context operations like applying display settings or configuring user preferences

Script editor

Write your script in the code editor. Click (x) in the bottom right corner of the editor to insert a variable, system variable, or custom field reference at the cursor position.

Script Editor - Variable Picker

Selecting an item inserts it as {{variable_name}} at the cursor. Level resolves the value at runtime before the script executes.

πŸ’‘ TIP: System variables like Device hostname and Device nickname don't require any setup β€” they're always available. Automation variables (listed under Variables) are scoped to the current automation and must be created first, either from the automation's Variables menu or by a prior action. Custom fields you've defined in your organization also appear in the picker and resolve to that device's field value at runtime.


Exit Codes

Level uses the script's exit code to determine whether the action succeeded or failed.

Exit code

Result

0

Action marked as successful

Non-zero (e.g. 1)

Action marked as failed

Your On action failure setting in Additional options controls what happens next β€” whether the pipeline stops or continues.

Make sure your scripts exit explicitly with the appropriate code. If a script exits 0 after encountering an error it didn't handle, Level will treat the action as successful.


Conditions

The Conditions section lets you restrict when this action runs based on device attributes or the outcome of a previous action.

See Action Conditions for the full reference on condition types, operators, and values.


Additional Options

Expand Additional options for action name, failure behavior, output variable assignment, retries, and the enabled toggle.

See Actions Overview for the full reference on additional options available on every action.


FAQ

  • What's the difference between Shell and Run Script? Shell writes the script directly in the action panel β€” it's not saved to your script library. Run Script executes a saved script that can be reused across automations. Use Shell for quick one-off commands; use Run Script when the same logic needs to be maintained or shared.

  • What happens if the script times out? The action is marked as failed. The On action failure setting in Additional options controls whether the pipeline stops or continues.

  • Can a Shell script set an automation variable? Yes β€” two ways. Use the inline {{variable_name=value}} syntax anywhere in your script output to set a script variable; that script variable then needs to be mapped to an automation variable in the action panel to be available to subsequent actions. Or use Assign action output to variable in Additional options to capture the script's full stdout directly into an automation variable without any additional mapping. See Set Variables Directly from Scripts for the inline syntax details.

  • Who can add or modify Shell actions? Technicians with permission to edit automations in the relevant group. See Workspace β†’ Permissions for access control configuration.

Did this answer your question?