Home » Infrastructure » Linux » script to check if db is up and exit if it not
script to check if db is up and exit if it not [message #584481] Tue, 14 May 2013 12:27 Go to next message
sbk785
Messages: 5
Registered: May 2013
Junior Member
hi

i have a script that first checks if the db is open:
if yes ... i have other conditions to run through.
But if the db is not open or available
i dont want to read the remaining lines in the script and exit immediately
environment variables exported ..
can someone help me with a way to stop and exit the script if my first condition fails.
here is what im trying:

log=/opt/oracle
sqlplus -s system/{pwd.} << EOF >$log
select open_mode from v\$database;
EOF

condiiton 2 ..3.. ,,

regards
sk

[Updated on: Tue, 14 May 2013 12:28]

Report message to a moderator

Re: script to check if db is up and exit if it not [message #584483 is a reply to message #584481] Tue, 14 May 2013 13:00 Go to previous message
Michel Cadot
Messages: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
In SQL*Plus:
whenever sqlerror exit 1

In shell script after SQL*Plus:
if [ $? -ne 0 ]; then exit 1; fi

Regards
Michel

[Updated on: Tue, 14 May 2013 13:02]

Report message to a moderator

Previous Topic: SFTP locsite unit=vts3 equivalant command
Next Topic: expdp dumpfile owner/group change
Goto Forum:
  


Current Time: Wed Dec 11 16:27:23 CST 2024