Skip to main content

What You’ll Learn

  • Running shell commands for system info
  • Running Python one-liners and multi-line scripts
  • Writing scripts to the sandbox filesystem and executing them
  • Using shell pipelines (sort, uniq, etc.)
  • All within a single sandbox session
  • Proper cleanup with try/finally and sbx.kill()

Prerequisites

This example is available in Python. TypeScript version coming soon.

Code Walkthrough

Shell commands — run any system utility directly:
Python one-liner — invoke python3 -c for quick computations:
Write and execute a Python script — use sbx.files.write() to upload code, then run it:
Shell pipeline — chain Unix utilities:
Shell script — write a .sh file and run it with sh:

Expected Output