vers execute
Execute a command within the Vers environment on the specified VM.
Commands must be wrapped in quotes! Use vers execute "command" not vers execute command
Usage
vers execute "" # Run on current HEAD VM
vers execute [vm-id|alias] "" # Run on specific VM
Options
| Option | Description |
|---|
--host | Specify the host IP to connect to (overrides default) |
Examples
Execute on HEAD VM
vers execute "ls -la"
vers execute "python app.py"
vers execute "systemctl status nginx"
Execute on specific VM
vers execute vm-abc123 "ps aux"
vers execute my-alias "tail -f /var/log/app.log"
Commands with pipes and redirections
# Always use quotes for complex commands
vers execute "ps aux | grep python"
vers execute "find /app -name '*.py' | wc -l"
vers execute "echo 'Hello World' > /tmp/test.txt"
vers execute "grep -r 'error' /var/log/ | head -10"
Development and testing
vers execute "npm test"
vers execute "python -m pytest tests/"
vers execute "curl -f http://localhost:3000/health"
vers execute "df -h"
How it works
The execute command provides a way to run single commands on VMs without opening an interactive SSH session:
- VM detection: If no VM is specified, uses the current HEAD VM
- SSH connection: Establishes a secure connection using managed SSH keys
- Command execution: Runs the command as root inside the VM
- Output streaming: Returns stdout/stderr directly to your terminal
- Exit code preservation: Maintains the original command’s exit status
Argument handling
The command intelligently handles VM identification:
- One argument: Treats as command, runs on HEAD VM
- Two+ arguments: First argument attempted as VM identifier
- If valid VM: runs command on that VM
- If invalid VM: treats all arguments as command, runs on HEAD VM
Prerequisites
- VM must be in “Running” state
- VM must have SSH port configured
- Valid authentication (handled automatically)
See Also