Skip to main content
Connect to interactive terminal sessions in HopX sandboxes using the terminal command (alias: term). Access WebSocket-based terminal sessions for interactive shell access.

Command Syntax

hopx terminal <subcommand> [options]

Subcommands

connect

Connect to an interactive terminal session. Syntax:
hopx terminal connect SANDBOX_ID [OPTIONS]
Arguments:
  • SANDBOX_ID - Sandbox ID (required)
Options:
  • --command TEXT - Command to execute (default: interactive shell)
  • --timeout INTEGER - Connection timeout in seconds
Examples:
# Connect to interactive terminal
hopx terminal connect sb_abc123

# Execute command and exit
hopx terminal connect sb_abc123 --command "ls -la"

# Connect with timeout
hopx terminal connect sb_abc123 --timeout 60
Expected Output:
Connected to terminal session
$ 
Exit Codes:
  • 0 - Success
  • 3 - Authentication error
  • 4 - Sandbox not found
  • 5 - Connection timeout

info

Get terminal information for a sandbox. Syntax:
hopx terminal info SANDBOX_ID [OPTIONS]
Arguments:
  • SANDBOX_ID - Sandbox ID (required)
Options:
  • --output, -o FORMAT - Output format: table, json, plain (default: table)
Examples:
# Get terminal info
hopx terminal info sb_abc123

# Get info with JSON output
hopx terminal info sb_abc123 --output json
Expected Output (Table):
┌─────────────┬─────────────────────────────────────┐
│ Property    │ Value                               │
├─────────────┼─────────────────────────────────────┤
│ Status      │ active                              │
│ WebSocket   │ wss://...                           │
│ Terminal    │ /bin/bash                           │
└─────────────┴─────────────────────────────────────┘
Exit Codes:
  • 0 - Success
  • 3 - Authentication error
  • 4 - Sandbox not found

url

Get WebSocket URL for terminal access. Syntax:
hopx terminal url SANDBOX_ID [OPTIONS]
Arguments:
  • SANDBOX_ID - Sandbox ID (required)
Examples:
# Get terminal WebSocket URL
hopx terminal url sb_abc123
Expected Output:
wss://terminal-sb_abc123.us-east.vms.hopx.dev/
Exit Codes:
  • 0 - Success
  • 3 - Authentication error
  • 4 - Sandbox not found

Interactive Terminal Usage

When connected to an interactive terminal:
  • Type commands as you would in a normal terminal
  • Press Ctrl+C to interrupt running commands
  • Press Ctrl+D or type exit to disconnect
  • Use arrow keys for command history
  • Tab completion is available

Shell Scripting Examples

Connect and Execute Commands

#!/bin/bash

# Connect and run commands
echo "ls -la" | hopx terminal connect sb_abc123 --command "bash"

Get Terminal URL for External Tools

#!/bin/bash

# Get terminal URL for use with external WebSocket clients
TERMINAL_URL=$(hopx terminal url sb_abc123)
echo "Terminal URL: $TERMINAL_URL"

Next Steps