pvesh command list

LnxBil

Well-Known Member
Feb 21, 2015
4,095
388
83
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"]}'
 

LnxBil

Well-Known Member
Feb 21, 2015
4,095
388
83
Germany
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?
 

dcsapak

Proxmox Staff Member
Staff member
Feb 1, 2016
3,798
345
83
31
Vienna
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
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!