Overview
CommandResult is a Pydantic model that encapsulates the output and status of a command executed on a guest VM. It is returned by vm.run() and provides both raw output streams and convenience properties.
Fields
The exit code returned by the command. A value of
0 typically indicates success, while non-zero values indicate errors.The complete standard output captured from the command execution. This contains all text written to stdout by the process.
The complete standard error output captured from the command execution. This contains all text written to stderr by the process.
Properties
ok
True if exit_code == 0, False otherwise.
Example:
output
stdout.strip(), removing leading and trailing whitespace. Useful for cleaner output in most cases.
Example:
Usage Examples
Basic Command Execution
Error Handling
Checking Command Success
Parsing Command Output
Handling Both Streams
Immutability
CommandResult is a frozen Pydantic model, meaning instances are immutable after creation. This ensures the integrity of command results.
Related
- SmolVM.run() - Execute commands and get CommandResult
- Exceptions - Command execution errors