Skip to Content

Shell

Overview

The Shell operator is a way to run one or more commands in a shell.

Examples

Simple static command

Config

name: shell-pwd nodes: - id: start operator: HTTPIn method: GET routes: - /shell-pwd - id: b2j operator: BufferToJSON - id: shell operator: Shell command: ls args: - -al edges: - { from: start, to: b2j } - { from: b2j, to: shell }

Request

curl -v http://localhost:2243/shell-pwd

Response

[ "{\"line\":\"Exactly one argument expected.\",\"type\":\"err\"}", "{\"line\":\"Usage: terraform [global options] state show [options] ADDRESS\",\"type\":\"out\"}", "{\"line\":\"\",\"type\":\"out\"}", "{\"line\":\" Shows the attributes of a resource in the Terraform state.\",\"type\":\"out\"}", "{\"line\":\"\",\"type\":\"out\"}", "{\"line\":\" This command shows the attributes of a single resource in the Terraform\",\"type\":\"out\"}", "{\"line\":\" state. The address argument must be used to specify a single resource.\",\"type\":\"out\"}", "{\"line\":\" You can view the list of available resources with \\\"terraform state list\\\".\",\"type\":\"out\"}", "{\"line\":\"\",\"type\":\"out\"}", "{\"line\":\"Options:\",\"type\":\"out\"}", "{\"line\":\"\",\"type\":\"out\"}", "{\"line\":\" -state=statefile Path to a Terraform state file to use to look\",\"type\":\"out\"}", "{\"line\":\" up Terraform-managed resources. By default it will\",\"type\":\"out\"}", "{\"line\":\" use the state \\\"terraform.tfstate\\\" if it exists.\",\"type\":\"out\"}", "{\"type\":\"exit\"}" ]

One-off command execution

Config

name: shell nodes: - id: start operator: HTTPIn method: POST routes: - /shell - id: translate operator: MessageTranslator mode: json template: | { "command": data.data } - id: shell operator: Shell command: bash # args: # - "-i" edges: - { from: start, to: translate } - { from: translate, to: shell }

Request

curl -v http://localhost:2243/shell -d '{"data": "echo hello; exit"}'

Response

[ "{\"line\":\"hello\",\"type\":\"out\"}", "{\"type\":\"exit\"}" ]

Interactive shell

name: ws-shell nodes: - id: start operator: HTTPIn ws: true method: ^(ANY)$ routes: - /ws-shell - id: b2j operator: BufferToJSON - id: translate operator: MessageTranslator mode: json template: | { "command": data.data } - id: shell operator: Shell command: bash # args: # - "-i" edges: - { from: start, to: b2j } - { from: b2j, to: translate } - { from: translate, to: shell }

Configuration Reference

name

Must be 'Shell'

Stringrequired

command

The command to call

Stringrequired

args

The arguments for the command

Stringrequired