run_command() method executes a short-lived command inside your active sandbox container and waits for it to finish before returning the output.
It’s ideal for quick, synchronous tasks such as listing files, checking Python or Node.js versions, or running lightweight scripts that complete within a few seconds.
This method captures both stdout and stderr once the command completes. Because it’s optimized for speed and simplicity, run_command() has a strict 5-second execution limit and does not support streaming output.
run_command(cmd: str, args: Optional[List[str]] = None) -> dict
Description:Executes a short command (< 5 seconds) and returns its standard output and standard error.
For longer-running or streaming processes, use
run_streaming_command() instead.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd | str | Yes | Command to execute (e.g. "python3", "ls", "echo") |
args | List[str] | No | List of command arguments |
Returns:
- 5 second maximum : Command will timeout
- No streaming - must wait for completion
- No exit code returned (use
runStreamingCommandif you need it)
