Skip to main content

What You’ll Learn

  • Streaming command output with sbx.commands.run_stream() (Python) / sbx.commands.runStream() (TypeScript)
  • Real-time on_stdout / on_stderr callbacks that fire as each line arrives
  • Inspecting the final accumulated CommandResult after the stream completes
  • Proper cleanup with try/finally and sbx.kill()

Prerequisites

Code Walkthrough

Use run_stream() with on_stdout and on_stderr keyword callbacks. The call blocks until the command exits and returns a CommandResult with the full accumulated output:
Each line is delivered to on_stdout as it is emitted — no buffering until the command finishes. The returned result.stdout contains all lines joined together.

Expected Output