MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / newGuestsExecCmd

Function newGuestsExecCmd

internal/cli/guests.go:472–500  ·  view source on GitHub ↗

── guests exec ──────────────────────────────────────────────────────────────

()

Source from the content-addressed store, hash-verified

470// ── guests exec ──────────────────────────────────────────────────────────────
471
472func newGuestsExecCmd() *cobra.Command {
473 cmd := &cobra.Command{
474 Use: "exec <vmid> <command>",
475 Short: "Execute a command inside a guest via QEMU guest agent",
476 Long: `Execute a shell command inside a running guest.
477
478For QEMU VMs the command runs via the QEMU guest agent (no SSH to the guest
479required). The VM must have the guest agent enabled and running.
480On Linux guests the command runs via /bin/sh -c.
481On Windows guests it runs via PowerShell.
482
483For LXC containers the command runs via pct exec over SSH to the Proxmox node
484(ssh_user must be configured). The command always runs via /bin/sh -c.
485
486Note: unlike the command-runner plugin, exec imposes no command whitelist.
487The caller is responsible for what they run. Security is enforced by the
488Proxmox API token permissions and SSH access granted to this client.`,
489 Example: ` pvetui guests exec 100 "uptime"
490 pvetui guests exec 200 "df -h"
491 pvetui --profile prod guests exec 100 "systemctl status nginx"`,
492 Args: cobra.ExactArgs(2),
493 ValidArgsFunction: completeVMIDs,
494 RunE: runGuestsExec,
495 }
496
497 cmd.Flags().Duration("timeout", 30*time.Second, "Command execution timeout")
498
499 return cmd
500}
501
502func runGuestsExec(cmd *cobra.Command, args []string) error {
503 vmid, err := parseVMID(args[0])

Callers 1

newGuestsCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected