Skip to main content

Shell

Execute a command through /bin/sh -c. Supports shell features like pipes, redirects, and variable expansion.

$ osapi client node command shell --command "ls -la /tmp | grep log"

Job ID: 550e8400-e29b-41d4-a716-446655440000

HOSTNAME CHANGED STDOUT STDERR EXIT CODE DURATION
server1 false -rw-r--r-- 1 root root 4096 … 0 15ms

Long output is truncated in the table view. Use --json for the full response data.

Use shell syntax like pipes and redirects:

$ osapi client node command shell \
--command "df -h / | tail -1 | awk '{print \$5}'" \
--timeout 10

Execute in a specific working directory:

$ osapi client node command shell \
--command "cat *.conf | wc -l" \
--cwd /etc

When targeting all hosts, the CLI prompts for confirmation:

$ osapi client node command shell --command "hostname -f" --target _all

This will execute shell command on ALL hosts. Continue? [y/N] y

Job ID: 550e8400-e29b-41d4-a716-446655440000

HOSTNAME CHANGED STDOUT STDERR EXIT CODE DURATION
server1 false server1.example.com 0 5ms
server2 false server2.example.com 0 7ms

Target by label to execute on a group of servers:

$ osapi client node command shell \
--command "systemctl is-active nginx" \
--target group:web

JSON Output

Use --json to get the full untruncated API response:

$ osapi client node command shell --command "uname -r" --json

Flags

FlagDescriptionDefault
--commandThe shell command to execute (required)
--cwdWorking directory for the command
--timeoutTimeout in seconds (max 300)30
-T, --targetTarget: _any, _all, hostname, or label (group:web)_any
-j, --jsonOutput raw JSON response