I have a script which prompts for user credentials in order to phrase a curl command. The issue I am having is if the password has a special character it can mess up the curl command.
example code:
curl -k -o ~/Desktop/output.txt https://$name:$password@'server.example.com/serverpage.asp?action=MakeList&User='$enduser
example inputs
name:test
password:P@55w0rd!
output:
curl: (6) Could not resolve host: 55w0rd!@server.example.com; nodename nor servname provided, or not known
I understand that the curl command is hitting the "@" in the password and trying to connect to 55w0rd!@server.example.com in stead of server.example.com.
How do I "sanitize" the input to escape special characters?
Thank you!