[SOLVED] Using 'cat' to create files via 'pct exec'

joshy

New Member
Aug 10, 2022
3
0
1
Hi Forum,

I am trying to use cat to create a file via pct exec.

But I cannot work out the correct syntax to achieve. The folder I want to write to exists, below is the syntax I have attempted.

Code:
root@pve:~# pct exec 404 ls /etc/systemd/system/deluged.service.d
root@pve:~# pct exec 404 cat <<'EOF' > /etc/systemd/system/deluged.service.d/user.conf 
[Service] 
User=debian-deluged 
Group=debian-deluged 
EOF
-bash: /etc/systemd/system/deluged.service.d/user.conf: No such file or directory

Could I also ask what the -- means here. I have seen some examples with this. In the below both return the same data

Code:
rroot@pve:~# pct exec 404 cat /etc/hosts
root@pve:~# pct exec 404 -- cat /etc/hosts
 
pct exec ${ID} -- tee /etc/systemd/system/deluged.service.d/user.conf <<EOF
...
EOF

Works
 
Else - I'd say - use `pct push` and `pct pull` (see `man pct`)

I hope this helps!