I have a question that mix Linux / Unix shell-scripting and sqlplus (Oracle) that is driving me crazy. :-)
sqlplus utilize a syntax like this:
./sqlplus johnF/[email protected]:1521/SID
And it works fine. However my password is not simple as "mypassword", it utilize "!" and "@" and sometimes even "\". For this example, let's suppose that my password is !p@ssword
If I use the following syntax in sqlplus it works:
./sqlplus johnF/'"!p@ssword"'@127.0.0.1:1521/SID
That's great. However I wanted to use it in a shell script that get call sqlplus and get many parameters from files (username, password, SID and SQL QUERY), just for example let me use a reduced code.
#!/bin/bash
while IFS=: read -r line
do
echo "./sqlplus johnF/[email protected]:1521/SID"
echo -e 'select 1 from dual;\nexit;' | ./sqlplus johnF/[email protected]:1521/SID
done < $1
I have attempted to fix it in many ways, including:
echo -e 'select 1 from dual;\nexit;' | ./sqlplus johnF/'"$line"'@127.0.0.1:1521/SID
echo -e 'select 1 from dual;\nexit;' | ./sqlplus johnF/'\"$line\"'@127.0.0.1:1521/SID
echo -e 'select 1 from dual;\nexit;' | ./sqlplus johnF/\'\"$line\"\'@127.0.0.1:1521/SID
And many others and all fails, in a few cases the first echo print the output exactly as it should be passed to sqlplus, but it never works, returns login denied (wrong password) or connection issues (maybe the @ being intercepted as wrong target).
How to solve this puzzle?
Thanks.
alter user johnF identified by ???
statement? – Barbaros Özhan