how to check DB connection in unix shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to check DB connection in unix shell script
# 1  
Old 10-31-2008
how to check DB connection in unix shell script

In the following script I need to find whether DB is established successfully or not. I need to find and display it.

If <DB is connected successfully> then
echo "DB connection success"
else
echo "DB connection failure"
fi

In the same way I need to do it for DB terminate.

I don't know the syntax for that.

Code:
#! /bin/ksh
############################
#   AFI Monitor Script
############################
. /db2/uszlad48/sqllib/db2profile
export mondir=/home/bmwdev1/script/krishna/arc
export monlog1=$mondir/fscdlog1.log
extractcount=0
deletecount=0
notdeletecount=0
# connect to DB
db2 "connect to r2pdev user bmwdevup using summer08"
 
db2 -x "selec * from table" >> $monlog1

# disconnect from DB2
db2 terminate
 
exit 0

Can any one help me to fix this problem

Krishnakanth Smilie
# 2  
Old 10-31-2008
I'm not a db2 expert, but the best way to test a database is to create a small test table within the database with only one filed most likely the actual date.
testing steps:
* update the date field with the current date
* select the date filed
compare the result.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check email with attachment received or not from UNIX shell script?

Hello Guys, Here is the requirement!! I want to check the mail with attachment received or not through unix scripting. And send an notification email when mail with attachment already received. Any thoughts on this is much appreciated!! Regards, Harry (0 Replies)
Discussion started by: dharry2017
0 Replies

2. Shell Programming and Scripting

Need Script to check the FTP connection

Hi, I need a script which check the FTP connections, if its working fine then no issue. Incase not working fine then Trigger the mail. Please help on this. Thanks (4 Replies)
Discussion started by: Keshav Kalra
4 Replies

3. Shell Programming and Scripting

Check SQL through UNIX shell script

I use below command to log in to oracle database sqlplus username/passwordWhen i enter into sql prompt i press quitIf there are any errors it will show just below the output of sqlplus username/password. The errors generally start with keyword ORA can we do this by using a unix shell script.?... (4 Replies)
Discussion started by: Nakul_sh
4 Replies

4. Shell Programming and Scripting

Check the connectivity of the DB through script, exit if no connection

check the connectivity of the DBs through script, script should exit if no connection and display the output as below. connectivity for DB1 is OK connectivity for DB2 is OK connectivity for DB3 is FAILED for DB in 1 2 3 do (sqlplus -s... (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

simple while loop script to check a connection

Hi, I am completely new to shell scripting. Basically I am wanting to create a simple while loop script to check if a network connection is available from 'netstat -a' and if its present then output a character to the serial port. I think i am nearly there.. but need some assistance.. this is... (9 Replies)
Discussion started by: zippyzip
9 Replies

6. Shell Programming and Scripting

BatchScript/Unix shell Script to check folder in Windows server

Hi, It will be great help if any of them can provide or tell which scripting is possible to write for checking folder exists or not in Windows server from Unix/Windows machine. If folder doesn't exist then need to create the folder through script and copy the files. It is on very... (1 Reply)
Discussion started by: prakashchakra7
1 Replies

7. Shell Programming and Scripting

check the DB connection through Unix

Hi all, I have written the script to check the connectivity of the Database ,the scripts show me the correct error when i try to give the wrong credential's but it also show Connected and trigger's the child jobs which that should not happen , whenever the connection is not established properly... (2 Replies)
Discussion started by: bshivali
2 Replies

8. Shell Programming and Scripting

Review Check list for Unix Shell Script

Hi, I need Unix Shell Script Review Check list in the format of word or excel. Can any one provide the review checklist for unix shell script. Pls. (1 Reply)
Discussion started by: praka
1 Replies

9. UNIX for Dummies Questions & Answers

How to check path exist or not in UNIX shell script

UNIX Shell Script I'm in /home/suneel dirctory in that directory need to check for a path for example com/src/resources If Path exists need to copy the files from one directory If path not exist need to create the folders and copy the files UNIX shell script help required (3 Replies)
Discussion started by: suneelc
3 Replies

10. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies
Login or Register to Ask a Question