API equivalent of qm guest exec

Hyien

Member
Jun 18, 2021
95
3
13
35
what's the api of pvesh equivalent of qm guest exec?

eg. qm guest exec 100 '/bin/ls' -- '-ald' '/tmp'

i tried pvesh create /nodes/xxx/qemu/100/agent/exec -command 'ls -ald /tmp', but it's giving me an error:
Wide character in die at /usr/share/perl5/PVE/RESTHandler.pm line 869.

also, i noticed qm shows the command output, but pvesh returns just the pid
 
you have to specify the 'command' arg for each part of the command:
Code:
pvesh create /nodes/xxx/qemu/100/agent/exec -command 'ls' --command '-ald' --command '/tmp'

and then feed the pid into exec-status (qm guest exec does this by default)
Code:
pvesh get /nodes/xxx/qemu/100/agent/exec-status --pid 12345