What You’ll Learn
- Running a basic shell command with
sbx.commands.run() - Passing environment variables via the
envsparameter - Setting the working directory via the
cwdparameter - Handling failing commands by inspecting
exit_codeandstderr - Running multi-line / chained commands with
&& - Proper cleanup with
try/finallyandsbx.kill()
Prerequisites
Code Walkthrough
- Python
- TypeScript
Basic command — Environment variables — pass a dict via Working directory — set with Failing commands — non-zero exit codes do not raise exceptions by default:Chained commands — use shell operators:
result.stdout contains the captured output:envs:cwd: