Apex installed status
#!/bin/bash
# Log file
LOGFILE="apex_check.log"
echo "Checking APEX installation on all running Oracle databases..." > $LOGFILE
# Find running Oracle instances (excluding ASM and APX)
ps -ef | grep pmon | grep -v grep | grep -Ev "(\+ASM|APX)" | awk -F'_' '{print $3}' | while read -r ORACLE_SID
do
if [[ -n "$ORACLE_SID" ]]; then
echo "Processing database: $ORACLE_SID" | tee -a $LOGFILE
# Set Oracle environment
export ORACLE_SID=$ORACLE_SID
export ORAENV_ASK=NO
. oraenv > /dev/null 2>&1
# Run SQL query to check APEX installation
SQL_OUTPUT=$(sqlplus -s / as sysdba <<EOF
SET PAGES 1000;
SET HEADING OFF;
SET FEEDBACK OFF;
COL comp_id FOR A12;
COL comp_name FOR A35;
COL version FOR A12;
COL status FOR A12;
SELECT comp_id, comp_name, version, modified, status
FROM dba_registry
WHERE comp_id='APEX';
EXIT;
EOF
)
# Process the result
if [[ -z "$SQL_OUTPUT" ]]; then
echo "Database: $ORACLE_SID - APEX is NOT installed" | tee -a $LOGFILE
else
echo "Database: $ORACLE_SID - APEX is installed" | tee -a $LOGFILE
echo "$SQL_OUTPUT" | tee -a $LOGFILE
fi
fi
done
echo "APEX check completed. Log saved in $LOGFILE"
Comments
Post a Comment