0
votes

I have a db.txt that contains oracle db username and password

oracle_user=username        
oracle_password=password

Then I have a shell script, mytest.sh, to call the username and password in db.txt. Store into variables and run test.sql file by sqlplus

#!/bin/sh      
. db.txt      
SCRIPT_HOME=/myhome/mytest        
ORACLE_BASE=/opt/oracle        
ORACLE_HOME=/opt/oracle/product/11.2.0/dbhome        
ORACLE_SID=mysid        
ORACLE_USER=$oracle_user        
ORACLE_PASSWORD=$oracle_password        
export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_USER ORACLE_PASSWORD;         
SQL=$SCRIPT_HOME/test.sql        

$ORACLE_HOME/bin/sqlplus $ORACLE_USER/$ORACLE_PASSWORD@$ORACLE_SID @$SQL

However when I run the mytest.sh, it returns

ERROR:
ORA-01017: invalid username/password; logon denied

Is the variables read from text file cannot put into sqlplus command directly?

1

1 Answers

0
votes

At first glance script looks ok. 1. Are you sure credentials are correct? 2. Could you echo "$ORACLE_USER/$ORACLE_PASSWORD" before calling sqlplus to make sure you're passing valid details