Check database availability via ksh script
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