Skip to main content

What You’ll Learn

  • Running a basic shell command with sbx.commands.run()
  • Passing environment variables via the envs parameter
  • Setting the working directory via the cwd parameter
  • Handling failing commands by inspecting exit_code and stderr
  • Running multi-line / chained commands with &&
  • Proper cleanup with try/finally and sbx.kill()

Prerequisites

Code Walkthrough

Basic commandresult.stdout contains the captured output:
Environment variables — pass a dict via envs:
Working directory — set with cwd:
Failing commands — non-zero exit codes do not raise exceptions by default:
Chained commands — use shell operators:

Expected Output