pvesh command list

LnxBil

Distinguished Member
Feb 21, 2015
9,692
1,886
273
Saarland, Germany
Hi,

I tried to run a command via the new qemu command api endpoint via pvesh, but do not know how to format this correctly. I haven't found any hints or usage examples in the usual places.

Code:
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command id
┌─────┬───────┐
│ key │ value │
├─────┼───────┤
│ pid │ 1708  │
└─────┴───────┘
root@proxmox ~ > pvesh get /nodes/proxmox/qemu/109/agent/exec-status -pid 1708
┌──────────┬────────────────────────────────────────┐
│ key      │ value                                  │
├──────────┼────────────────────────────────────────┤
│ exitcode │ 0                                      │
├──────────┼────────────────────────────────────────┤
│ exited   │ 1                                      │
├──────────┼────────────────────────────────────────┤
│ out-data │ uid=0(root) gid=0(root) groups=0(root) │
└──────────┴────────────────────────────────────────┘

Now with arguments:

Code:
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command id 0
400 too many arguments
pvesh create <api_path> --command <string> [OPTIONS] [FORMAT_OPTIONS]
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command "id 0"
Agent error: Guest agent command failed, error was 'Failed to execute child process "id 0" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command "id,0"
Agent error: Guest agent command failed, error was 'Failed to execute child process "id,0" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command "'id','0'"
Agent error: Guest agent command failed, error was 'Failed to execute child process "'id','0'" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command "['id','0']"
Agent error: Guest agent command failed, error was 'Failed to execute child process "['id','0']" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command "{['id','0']}"
Agent error: Guest agent command failed, error was 'Failed to execute child process "{['id','0']}" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command '{["id","0"]}'
Agent error: Guest agent command failed, error was 'Failed to execute child process "{["id","0"]}" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command '{"data" => ["id","0"]}'
Agent error: Guest agent command failed, error was 'Failed to execute child process "{"data" => ["id","0"]}" (No such file or directory)'
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command '{"data" => ["id","0"]}'
 
Oh, one way is actually

Code:
root@proxmox ~ > pvesh create /nodes/proxmox/qemu/109/agent/exec -command id -command 0
┌─────┬───────┐
│ key │ value │
├─────┼───────┤
│ pid │ 1786  │
└─────┴───────┘
root@proxmox ~ > pvesh get /nodes/proxmox/qemu/109/agent/exec-status -pid 1786
┌──────────┬────────────────────────────────────────┐
│ key      │ value                                  │
├──────────┼────────────────────────────────────────┤
│ exitcode │ 0                                      │
├──────────┼────────────────────────────────────────┤
│ exited   │ 1                                      │
├──────────┼────────────────────────────────────────┤
│ out-data │ uid=0(root) gid=0(root) groups=0(root) │
└──────────┴────────────────────────────────────────┘

Is there a shorter way?
 
correct, one possibility is there to shorten the pvesh command line

you do not have to type out '--command' everytime
you can also shorten the parameter to the point where it is unique, in this case down to 'c'
Code:
pvesh create /nodes/proxmox/qemu/109/agent/exec -c id -c 0