I have trouble getting curl to return a response. When I comment out the while loop or when I pass in a hardcoded URL, curl works perfectly. As you can see in the code below, curl does not work and displays an error "curl: (3) URL using bad/illegal format or missing URL". I suspect that "${REQUEST_STR}"
is the problem. Does anyone know a correct way to pass a string variable to curl? Thank you so much.
while read -r POS_SN
do
# echo "${POS_SN}"
REQUEST_STR="${BASE_URL}?usercode=${USER_CODE}&userpass=${USER_PASS}&sn=${POS_SN}"
echo "Request: ${REQUEST_STR}"
echo "Response: "
curl "${REQUEST_STR}"
done < "$input"
SOLUTION: I added IFS=$'\r'
to the line while IFS=$\'r' read -r POS_SN
and now curl works perfectly. I'm still not sure why it works but it works :)