Skip to main content
Execute code in HopX sandboxes using the run command. Supports Python, JavaScript, Bash, and Go with options for files, environment variables, and timeouts.

Command Syntax

Options

  • CODE - Code to execute as argument (use - to read from stdin)
  • --file, -f PATH - File containing code to execute
  • --sandbox, -s TEXT - Sandbox ID (creates temporary sandbox if omitted)
  • --template, -t TEXT - Template for temporary sandbox (default: code-interpreter)
  • --language, -l TEXT - Programming language: python, javascript, bash, go
  • --timeout INTEGER - Execution timeout in seconds
  • --env TEXT - Environment variable in KEY=VALUE format (repeatable)
  • --workdir TEXT - Working directory for execution
  • --output, -o FORMAT - Output format: table, json, plain (default: table)

Examples

Execute Python Code

Expected Output:

Execute JavaScript

Expected Output:

Execute Bash

Expected Output:

Execute from File

Expected Output:

Execute with Environment Variables

Expected Output:

Execute in Existing Sandbox

Expected Output:

Execute with Timeout

Execute from stdin

Expected Output:

JSON Output

Get JSON output for scripting:
Expected Output:

Exit Codes

  • 0 - Success
  • 1 - General error
  • 3 - Authentication error
  • 4 - Sandbox not found
  • 5 - Timeout

Shell Scripting Examples

Execute and Capture Output

Execute with Error Handling

Execute Multiple Scripts

Next Steps