When I have a situation where a command in a Bash shell script fails yet the same command with what I think are the same parameters works when I manually run it, I suspect an issue with either the parameter values or the parameter quoting.
As an initial step in isolating the problem, I'd suggest that immediately before the line
curl -u $USERNAMEVAL:$PWDVAL $URLVAL
you add something such as
echo "curl -u $USERNAMEVAL:$PWDVAL $URLVAL"
Or even (to be very clear):
echo "\$USERNAMEVAL(${#USERNAMEVAL}): \"$USERNAMEVAL\""
echo "\$PWDVAL(${#PWDVAL}): \"$PWDVAL\""
echo "\$URLVAL(${#URLVAL}): \"$URLVAL\""
echo "curl -u $USERNAMEVAL:$PWDVAL $URLVAL"
This prints the name, length, and value of each of the variables being used to construct the curl command.
E.g.:
#!/bin/bash
USERNAMEVAL='test\\test'
PWDVAL='test'
URLVAL='www.blah.com'
echo "\$USERNAMEVAL(${#USERNAMEVAL}): \"$USERNAMEVAL\""
echo "\$PWDVAL(${#PWDVAL}): \"$PWDVAL\""
echo "\$URLVAL(${#URLVAL}): \"$URLVAL\""
echo "curl -u $USERNAMEVAL:$PWDVAL $URLVAL"
This prints:
$USERNAMEVAL(10): "test\\test"
$PWDVAL(4): "test"
$URLVAL(12): "www.blah.com"
curl -u test\\test:test www.blah.com
$USERNAMEVAL?cat webservice.properties| grep -v ^#do name=$(echo $line | awk -F\= '{print $1}') value=$(echo $line | awk -F\= '{print $2}') #echo $name=$value if [ "$name" == "$URL" ]; then URLVAL=$value fi if [ "$name" == "$USERNAME" ]; then USERNAMEVAL=$value fi if [ "$name" == "$PWD" ]; then PWDVAL=$value fi done