The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
connect sqlplus from unix nehak UNIX for Dummies Questions & Answers 1 05-27-2008 09:12 AM
Shell Script And SQLPLUS maco_home UNIX for Dummies Questions & Answers 6 08-25-2007 01:05 PM
connect to sqlplus in a script big123456 Shell Programming and Scripting 1 09-18-2006 07:56 AM
calling sqlplus from shell suds19 Shell Programming and Scripting 2 10-24-2002 05:01 PM
sqlplus and shell scripting inquirer UNIX for Dummies Questions & Answers 10 08-16-2001 01:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-07-2007
aya_r aya_r is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 10
connect to sqlplus from shell

I'm writting a shell script and at the begining I login to sqlplus by
sqlplus -l user_name/password@instance
what I would like is to check if the database is down or not , and if the database has started moved to the next step else sleep for a certain time and then check again .
I know how to do the sleep part, but I don't know how to check if the database is not down. can some one help me please.

Thanks,
  #2 (permalink)  
Old 02-07-2007
Dhruva's Avatar
Dhruva Dhruva is offline
Registered User
  
 

Join Date: Mar 2006
Location: India
Posts: 255
you can check with $? status.if database is down you will not be able to connect with data base.

if [ $? != 0 ]
then
PROGRAM_STATUS=`echo NOT CONNECTED TO SQL`
fi

you may check another post here
  #3 (permalink)  
Old 02-07-2007
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
am using infomix database on unix os



Code:
if [ `tbstat - | grep On-Line | wc -l` -eq 0 ]
then
        echo Informix database seems to be down. Please start the database
        echo do this do this
else
        echo database is running
        echo do this
fi

where tbstat is used to find database status...here you have to find out the command which gives status of your database....
  #4 (permalink)  
Old 02-07-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Quote:
Originally Posted by aya_r
I'm writting a shell script and at the begining I login to sqlplus by
sqlplus -l user_name/password@instance
what I would like is to check if the database is down or not , and if the database has started moved to the next step else sleep for a certain time and then check again .
I know how to do the sleep part, but I don't know how to check if the database is not down.
[...]

For quick and "dirty" check you can use something like this:


Code:
oracheck ()
{
  printf "whenever sqlerror exit failure\nselect null from dual;\n" |
  sqlplus -sl user/pass 2>&- 1>&- || return 1
}


Usage:

until oracheck; do sleep n; done
go_to_the_next_step

  #5 (permalink)  
Old 02-07-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960
If its on Informix use
Code:
 onstat -

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0