Executes a command in an interactive pseudo-terminal (PTY) with support for terminal features like colors, cursor positioning, and interactive input.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/sandbox-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Method Signature
Parameters
Command to execute in the PTY. Typically used for interactive programs like shells, text editors, or TUI applications.
PTY configuration options
Returns
Examples
Run interactive shell command
Execute with custom terminal size
Send input to interactive program
Run vim in headless mode
Capture colored output
When to Use
UseexecInteractive when:
- Running commands that require a PTY (interactive shells, vim, htop)
- Capturing colored terminal output (test frameworks, build tools)
- Working with TUI applications
- Sending input to interactive programs
exec for:
- Non-interactive commands
- When you don’t need ANSI escape codes
- Better performance for simple commands
Terminal Features
PTY execution enables:- ANSI escape codes - Colors, cursor positioning, formatting
- Terminal size - Commands see proper COLUMNS and LINES env vars
- Raw mode - No line buffering, immediate character input
- Job control - Ctrl+C, Ctrl+Z signal handling
- Terminal type - TERM environment variable set
Related Methods
- exec - Execute non-interactive commands
- execStream - Stream command output
- proxyTerminal - Full terminal proxy for web clients