e2b_run_command
Execute a command inside an E2B sandbox and capture its output, errors, and exit code within a set timeout to verify behavior or retrieve results.
Instructions
Run a command in a sandbox and wait (up to timeoutMs) for it to finish, returning collected stdout/stderr/exit status. Uses the streaming process.Process/Start RPC under the hood.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cmd | Yes | Executable to run, e.g. 'bash' | |
| cwd | No | ||
| args | No | Arguments, e.g. ['-lc', 'echo hi'] | |
| envs | No | ||
| port | No | Optional envd port; defaults to 49983 | |
| username | No | ||
| sandboxId | Yes | E2B sandbox ID | |
| timeoutMs | No | How long to wait for the command to finish before returning partial output | |
| accessToken | No | Optional sandbox access token |