runCommand() method executes a single short-lived command inside your active sandbox container and waits until it finishes before returning the output. It’s ideal for quick tasks that complete within a few seconds: such as listing directories, checking Node.js or Python versions, or running lightweight scripts.
This method runs the command synchronously and captures both stdout and stderr once the execution is complete. Because it is optimized for speed and simplicity, runCommand() has a strict 5-second execution limit and does not support streaming output.
runCommand(options)
Description:
Executes a short command (< 5 seconds) and waits for completion. For longer operations, use runStreamingCommand().
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| cmd | string | Yes | Command to execute (e.g., ‘node’, ‘python’, ‘ls’) |
| args | string[] | No | Array of command arguments |
- 5 second maximum : Command will timeout
- No streaming - must wait for completion
- No exit code returned (use
runStreamingCommandif you need it)
