How To Create Bash Script to Perform Oracle Commands as Oracle on Target Server
Option 1:
1F=$(mktemp)
2printf "
3alter system set COMPATIBLE='19.3.0' scope=spfile;
4shutdown immediate;
5startup mount;
6alter database open;
7" > ${F}
8
9{oracleDbHome}/bin/sqlplus / as sysdba @${F}
10rm ${F}
Option 2:
1# Ensure ORACLE_HOME is set
2# Ensure ORACLE_BIN is set to $ORACLE_HOME/bin
3# Ensure ORACLE_BIN is in $PATH
4
5which sqlplus
6
7sqlplus /nolog <<EOF
8CONN {oracleUser.user}/{oracleUser.password}@{oracleUser.sid}
9SELECT * FROM DUAL
10EOF