Skip to main content
The 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:
ParameterTypeRequiredDescription
cmdstringYesCommand to execute (e.g., ‘node’, ‘python’, ‘ls’)
argsstring[]NoArray of command arguments
Returns:
Promise<{
  stdout: string  // Standard output
  stderr: string  // Standard error
}>
Example:
// Simple command
const result = await sandbox.runCommand({
  cmd: 'pwd'
})
console.log('Current dir:', result.stdout)
Limitations:
  • 5 second maximum : Command will timeout
  • No streaming - must wait for completion
  • No exit code returned (use runStreamingCommand if you need it)