I am trying to get a base64 encode to work and output to a variable in a bash script. The regular cli syntax is:
echo -ne "\0myuser@myhost.com\0mypass" | base64
But when I try putting this into a variable in a script it outputs, but a very small encoding, so I know it’s not working. My code in the script is:
auth=$(echo -ne "\0$user@$host\0$pass" | base64);
I know it has something to do with the quotes, but I’ve tried a myriad of thing’s with different quotes and singles and backslashes with no go.
Any thoughts?
EDIT: A bit more for the info. This should output with the user/pass/host above:
AG15dXNlckBteWhvc3QuY29tAG15cGFzcw==
But in the script it outputs:
LW5lIAo=
Ok, I’ll add this as an answer for the records’s sake:
Problem was in having
/bin/shas a default interpreter shell, which I assume, in this case wasdash.Test script used:
Results: