I'm reading password from input file and login with that password. However if password has special character then its failing. How can i make it work for the passwords with or without special characters? Have tried with '$pass' but looks it doesn't work.
ip="$(echo $line | awk -F ',' '{print $1}')"
pass="$(echo $line | awk -F ',' '{print $3}')"
output_json="$(curl -u admin:'$pass' -X GET -H "Content-Type:application/json" https://$ip:443/admin -k)"
Some issues with your current code:
echo $line
is not properly quoted, and will break on whitespace and other special characters; use echo "$line"
printf '%s\n' "$line"
would actually be safer than echo
, which may not work correctly depending on the contents of $line
admin:'$pass'
will resolve to the literal characters admin:$pass
being passed to curl
; use "admin:${pass}"
https://$ip:443/admin
is also not properly quoted, use "https://${ip}:443/admin"
$line
is being set with a literal password in the script you'll want single-quotes to have the shell ignore special characters; line='...,sbxy$sT_i7d6I*7'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.