This question already has an answer here:
- Trouble with read line script in Cygwin 3 answers
I have the following shell script in order to connect to database and do some tasks.
echo Please enter userid:
read USER_NAME
echo "Please enter password:"
read -s PASS
SID=${ORACLE_SID}
if [ "${ORACLE_SID}" != 'TEST' ]
then
sqlplus -s -l $USER_NAME/$PASS@$SID << EOF
copy from scott/tiger@orcl insert emp using select * from emp
exit
EOF
else
echo "Cannot copy"
fi
However 1when I execute I am getting errors
Please enter local Username:
scott
': not a valid identifierd: `USER_NAME
copy_data.sh: line 3: $'\r': command not found
Please enter local Password:
': not a valid identifierd: `
copy_data.sh: line 6: $'\r': command not found
copy_data.sh: line 8: $'\r': command not found
copy_data.sh: line 18: syntax error near unexpected token `fi'
copy_data.sh: line 18: `fi'
How can I resolve this issue
Debug mode
$ bash -x test.sh
+ echo 'please enter username'
please enter username
+ read user_name
vbx
+ echo 'please enter password'
please enter password
+ read -s pass
+ echo
test.sh: line 12: syntax error near unexpected token `else'
test.sh: line 12: `else'
syntax error near unexpected token
else'` – user75ponic Aug 22 '13 at 11:08