I have a server containing several different databases. I am trying to create a script that will ask the user which database they want to connect to, along with username and password, and then connect to it and perform remaining operations.
So far, I have written this:
awk 'BEGIN {FS=":"}!/^#/ && !/^\*/ && !/^$/{print $1":"$2}' ${ORATAB}
echo "Enter database instance name: "
read sid
export ORACLE_SID='echo $sid'
export ORACLE_HOME=`grep -i "^${ORACLE_SID}:" /etc/oratab | grep -v "^#" | cut -d ':' -f 2,2 `
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:/etc
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
sqlplus /nolog << EOF
CONNECT / as sysdba
select object_type,status,count(1) from dba_objects where owner='abc' and status='INVALID' group by object_type,status;
EXIT;
EOF
However, this block of code is not connecting to the database, nor does it seem to connect to the database either.
I am getting the following error: sqlplus: not found [No such file or directory]