Re: Is Oracle Running?

From: Tommy Wareing <p0070621_at_oxford-brookes.ac.uk>
Date: Tue, 24 May 1994 08:29:37 GMT
Message-ID: <CqAsxD.7ML_at_uk.ac.brookes>


Ian Dixon (idixon_at_syntaxis.ukmail.net) wrote:
> With version 6 this does not tell you if the database is usable. For
> instance, a shutdown is in progress or the database is up in dba
> mode.
 

> The command that I used at a former site was:
 

> echo "select 'Oracle is available' from dual;"|sqlplus -s /|
> fgrep Oracle||echo "Oracle unavailable. Contact Systems."
 

> It should all be on one line.

Our version is:

#! /bin/sh
# /mis/bin/oravail.sh
# Here's a shell script which checks whether Oracle is available:
# this can be run before trying to start up SQL*Menu, and therefore
# removing the possibility that users get stopped at the 'Enter
# user name and password' stage.
# (It's dependent on the fact that failing to get into sql returns
# a 0 error code, which is a bit dodgy of SQL, but works)
sqlplus -s / > /dev/null <<EOF
EXIT 2
EOF
case $? in
  1. exit 1 ;;
  2. exit 0 ;;
  3. exit 2 ;; esac exit 0

So an exit code of 0 means sqlplus is up, 1 means that sqlplus could not be executed (not on the path etc) and 2 means that sqlplus could be executed, but fell over for some reason (ie. database is not up)

--
  _________________________   __________________________________________
 /  Tommy Wareing          \ /  In the beginning, there was The Bomb    \
|  p0070621_at_brookes.ac.uk   X   And The Bomb said "Let there be Light!"  |
 \  0865-483389            / \     - The Bomb, Dark Star                /
  ~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Tue May 24 1994 - 10:29:37 CEST

Original text of this message