Database Administration (MOSC)

MOSC Banner

Check database availability via ksh script

edited Sep 4, 2013 10:30AM in Database Administration (MOSC) 12 commentsAnswered
db_status=`sqlplus -s "/ as sysdba" <<EOF
set heading off feedback off verify off
select status from v\\$instance;
exit
EOF`
if [ $db_status == 'OPEN' ]
then
 echo "database is open"
 #proceed to retrieve data from data dictionary
 sqlplus -s "/ as sysdba" <<! >> $OUTFILE

        set lines 132
        set wrap off
        select file_name from dba_data_files; 

else
 echo "database is unavailable"
fi

When I run the above, I get the following output for databases that are not available


database is open
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


That particular database is running if I check ps -ef|grep pmon

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center