var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: How to check if database exists via script.
First off I'm working with ASE 12.5.3.
I'm using you're basic ISQL command in a shell script to connect to my DB...
isql -S$DB_SERVER -D$DB_NAME -U$DB_USR -P$DB_PWD <<!EOF > $log_file
My question is, is there a way to determine if a database exists using a UNIX shell script?
For example, if somehow I can check if a database called DB_Test1 exists do the following...
isql -S$DB_SERVER -D$DB_Test1 -U$DB_USR -P$DB_PWD <<!EOF > $log_file
else do the following...
isql -S$DB_SERVER -D$DB_Test2 -U$DB_USR -P$DB_PWD <<!EOF > $log_file
Thanks for any help!
How come you don't know what database is on your server?
e.g. in ksh
isql -S$DB_SERVER -U$DB_USR -P$DB_PWD <<EOF | grep "$DB_NAME"
if [ $? -eq 0 ]
echo 'db found'
: do some stuff
echo 'db not found'
: do some other stuff
Thanks for the reply! I did a quick test and so far your solution looks like it will work for me.
Well I do know which database are on our servers, but the thing is that my script will run on several servers and not all of our servers have the same databases. So I'm trying to make my script as generic or adaptable as possible.
Thanks for your help!
Since you mentioned shell script its a bit easy. There might be other ways to do it, like do all processing in a stored proc.
isql ..... -b -o /tmp/myserver.dbs << EOF
set nocount on
select name from sysdatabases
#-b doesnt display any header
for i in `cat /tmp/myserver.dbs`
isql ..... << EOF
Sorry just read your original question... and my answer doesnt solve it... but I guess you get the picture and use some of the logic.