ActionShell, SHELL action

Syntax

Inside a callback action:

ActionShell("<command>"[, title=<title>])

Outside of a callback action:

self.r.action("SHELL","<command>"[, title=<title>])

Description

The SHELL action executes the specified command in the Bash shell of the underlying Linux operating system of the switch.

Parameters

<command>

A text string of the shell command as it would be entered at a Linux prompt.

The string can be either a single line or a multiline string with line breaks using any Python line break technique.

<title>

Specifies the title to be displayed for this action. The definition of <title> must use the Title function.

For example: title=Title("ps -aux")

Usage

The SHELL action takes a string as input and pipes it to the switch Bash shell.

For example, the following ActionShell request lists the current processes running on the switch:

ActionShell("ps -aux")

You can create a custom title for this action. The title you create can help the user of the Web UI to determine what action was executed. The title is displayed in the Action Results section of the Alert Details dialog box.

CAUTION:

Shell commands provide advanced and powerful access to the switch. Improper changes can make the switch inoperable, potentially requiring the switch to be zeroized.

The shell is enabled on the switch by default.

  • SHELL actions execute with root privileges.

  • The first SELL action in a script executes from the root (/) directory.

  • All Bash shell commands are supported as SHELL actions.

  • Command strings are passed without validation.

  • SHELL actions can be used with parameters.

Examples

Example of a SHELL action inside a callback action:

ActionShell("cd {}",[ self.params["path"])

Example of a SHELL action outside of a callback action:

self.r.action("SHELL", "cd {}",[ self.params["path"])

Example of a SHELL action that includes a custom title:

title=Title("cd {}",[ self.params["path"])
self.r.action("SHELL", "cd {}",[ self.params["path"], title=title)