I don't how to stop after 1st failed attempt, but here is a script that I
use to check if database is up or not.....

#!/usr/bin/ksh
#
# dbcheck : Script to check if datbase is up and accessible.
#                It tries to connect via SQL*Net (Net8) using a non-existing
userid and password.
#
# Author : Kirti Deshpande
#-----------------------------------------------
 
echo "Enter Name of the Database SID to check if it is accessible"
read DB

sqlplus -s << EOF > /tmp/$$.1
whenever sqlerror exit
aaa/aaa@$DB
exit;
EOF
egrep 'ORA-121|ORA-01034' /tmp/$$.1 > /dev/null
if [[ $? = 0 ]]
then
   echo "-----> '$DB' is _NOT_ Accessible\n" 
else
   grep 'ORA-01017' /tmp/$$.1 > /dev/null
   if [[ $? = 0 ]]
   then
     echo "-----> '$DB' is UP and Accessible\n" 
   else
     echo "-----> '$DB' is _NOT_ Accessible\n" 
   fi
fi
rm /tmp/$$.1

# --- End of File

HTH,

Regards,

- Kirti Deshpande 
  Verizon Information Services
   http://www.superpages.com

> -----Original Message-----
> From: Barry Deevey [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, September 18, 2001 10:46 AM
> To:   Multiple recipients of list ORACLE-L
> Subject:      Determining Oracle status
> 
> Hi all, 
> 
> I am trying to write a script in unix that determines if a specific oracle
> instance is available. I'm trying to avoid using the 'ps' command, so I
> thought the easiest method would be to connect via sqlplus - If it
> connects
> its up, if it doesn't then its unavailable. However, the problem is that
> when it isn't up, the script hangs and does not return anything - I think
> that this is because sqlplus by default gives you 3 attempts to logon, so
> even though the logon attempt failed, it is waiting for you to try again,
> so
> unfortunately I'm not getting a failed return code. 
> If anybody could tell me how to change this so that it only allows 1 login
> attempt before 'kicking you out' or whether there is a better method to
> finding out the status of an instance, I would be extremely grateful to
> hear
> from you. 
> 
> TIA for any responses. 
> 
> Best Regards, 
> Barry. 
> 
> 
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- 
> Author: Barry Deevey
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Deshpande, Kirti
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to