[Solved] Weird problem with "cat << "EOF" > ${OVPN_DIR}/${OVPN_ID}.auth"

Hi,
I am new on this forum.
During configuration OpenVPN client on GL.inet AR750S with OpenWRT ver.18 I found that this command:

OVPN_DIR="/etc/openvpn"
OVPN_ID="client"
OVPN_USER="USERNAME"
OVPN_PASS="PASSWORD"
 
umask go=
cat << "EOF" > ${OVPN_DIR}/${OVPN_ID}.auth
${OVPN_USER}
${OVPN_PASS}
EOF

create file /etc/openvpn/client.auth with this text inside:

${OVPN_USER}
${OVPN_PASS}

instead of:

USERNAME
PASSWORD

I do not know why it put variable name instead of variable value inside this file.
When I type:

root@GL-AR750S:~# ${TEST_VAR}
-ash: username: not found

It seems that variable is correctly created and can be used. What I am doing wrong?

Best regards
Arek

1 Like

You are right, it was a mistake, I updated the wiki.
Remove the quotes to expand variables properly:

cat << EOF > ...
...
EOF

Great, thank you.
It work without quotes.
If you can please update Wiki here too:

and here:

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

1 Like

The parts that expect variable/command expansion should be fixed now.
Some other sections in the extras may need to save the data as-is without expansion.

I marked as [Solved]

1 Like