Features
Running Commands
Execute shell commands and manage dependencies in the sandbox
The Sandbox SDK provides the run_command()
method to execute shell commands in your isolated sandbox environment.
The run_command()
Method
- command (
str
): The shell command to execute in the sandbox - Returns a dictionary with:
stdout
(str
): Standard output of the commandstderr
(str
): Standard error outputexit_code
(int
): Exit code of the process
Basic Usage
Running Multiple Commands
You can chain commands using &&
or run them in background:
Handling Results and Errors
Advanced Examples
Running Interactive or Long-Running Processes
For interactive sessions or long-running jobs, you can run in background:
Installing System Packages
Managing Working Directory
All commands are executed in the sandbox root by default. Use cd
to change directories:
Best Practices
- Use absolute paths (
/home/user/...
) to avoid ambiguity - Chain commands when appropriate to reduce round-trips
- Run long-running processes in background using
&
- Always check
exit_code
to handle errors programmatically