Run one command (no REPL)
Use borescope from scripts: run a single command and exit, or pipe a sequence of commands in on stdin.
Most of the time borescope is an interactive prompt. For scripts, aliases, and CI, you can run it non-interactively instead.
Run one command
Pass --command to run a single command and exit, without ever entering the
REPL:
$ borescope myapp/0 --command "services"
$ borescope myapp/0 --command "plan"
$ borescope myapp/0 --command "logs -n 100 myapp"
The command is parsed and run exactly as if you'd typed it at the prompt, including pipes:
$ borescope myapp/0 --command "logs -n 500 myapp | grep -i error"
Output goes to stdout, errors to stderr.
Exit codes
borescope's process exit code reflects what happened:
| Code | Meaning |
|---|---|
0 |
The command ran and reported success. |
1 |
The command failed, or discovery/connection failed (borescope: … on stderr). |
2 |
Usage error: no unit reference and no --here/--socket. |
That makes --command safe to use in shell conditionals:
$ if borescope myapp/0 --command "health" >/dev/null; then echo healthy; fi
Pipe a script on stdin
When borescope's stdin isn't a terminal and you haven't passed --command, it
reads commands from stdin one line at a time, runs each, and exits with the
status of the last:
$ borescope myapp/0 <<'EOF'
services
plan
logs -n 50 myapp
EOF
Or pipe a file:
$ cat checks.borescope | borescope myapp/0
Blank lines are skipped. This is handy for canned diagnostic runbooks you keep in version control.
Running container tools
exec works the same non-interactively, so you can reach any tool in the
container from a script:
$ borescope myapp/0 --command "exec cat /proc/1/cmdline"
$ borescope myapp/0 --command "exec ps aux"
Scripting tips
- Quote the whole command.
--command "logs -n 100 myapp"is one argument; borescope parses it the same way the REPL does. - Pick the model explicitly in automation with
--model, rather than relying on whatever model happens to be current. - Prefer
--snapshotwhen you want structured, machine-readable state rather than the human-formatted output of individual commands. See Capture a state snapshot. - One unit per invocation. borescope targets a single unit; loop in your shell to sweep several.