How to? Create or edit file with qm guest agent

jmjosebest

Renowned Member
Jan 16, 2009
192
30
93
Hello,

I'm trying to create /test.file with a test content, inside a VM.

Running directly in the VM, normally I can do:

Code:
echo test > /test.file

So, I expected that running this will work...

Code:
qm guest exec 100 echo test -- "> /test.file"

But seems is not working...

There is any way to do?

Thanks!
 
Last edited:
Found a solution :)

Code:
pvesh create /nodes/ns1000/qemu/100/agent/file-write --content "$(echo -e 'test')" --file "/test.file"

But it's strange that we can not do this with qm agent...
 
yes you can do it but you have to use a different command
guest agent executes a single program, not a shell, so if you want to use shell redirection you have to manually invoke the shell, e.g.

Code:
qm guest exec 100 -- /bin/sh -c "echo test > /test.file"
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!