Skip to main content
The commands module on a sandbox lets you run shell commands inside the sandbox. Commands have access to the full Linux userspace, can read and write the sandbox filesystem, and respect environment variables set at the sandbox or command level.

Run a command (blocking)

run() executes the command and waits for it to complete, then returns a CommandResult.

CommandResult model

Run options

Run with output callbacks

run() accepts on_stdout/on_stderr callbacks that are invoked after the command completes, iterating over the collected output lines. Each callback receives a plain str.
For true real-time streaming as the command produces output, use run_stream() / runStream() instead.

Background processes

Pass background=True to start a long-running process and get a CommandHandle back immediately.

CommandHandle

List running commands

ProcessInfo model

Send stdin to a running process

Kill a command

Wait for a command by PID

If you lost the CommandHandle reference, reconnect using connect() and call wait().

Error handling

commands.run() does not throw on non-zero exit codes — check result.exit_code yourself. However, handle.wait() (on background processes) always throws CommandExitException / CommandExitError on non-zero exit codes.

Multi-language execution

The default sandbox template includes Python 3, Node.js, Go, and standard shell utilities.