Decommission v1
#!/bin/bash # Check if ORACLE_SID is provided if [ -z "$1" ]; then echo "Error: ORACLE_SID not provided." echo "Usage: $0 <ORACLE_SID>" exit 1 fi # Set environment variables using oraenv export ORAENV_ASK=NO export ORACLE_SID=$1 oraenv LOG_FILE="decommission_$ORACLE_SID.log" log() { local message=$1 echo "$(date +'%Y-%m-%d %H:%M:%S') $message" | tee -a $LOG_FILE } log "Decommissioning process started for ORACLE_SID: $ORACLE_SID" db_unique_name=$(sqlplus -s / as sysdba <<EOF set heading off set feedback off set pagesize 0 select db_unique_name from v\$database; exit; EOF ) db_unique_name=$(echo $db_unique_name | xargs) # trim spaces log "Retrieved database unique name: $db_unique_name" # Helper function to execute SQL commands run_sql() { sqlplus -s "/ as sysdba" <<EOF $1 exit; EOF } # Helper function to execute DGMGRL commands and capture output run_dgmgrl() { dgmgrl...