If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Problem in finding the file in sqllib (link directory)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-16-09, 07:00
sekhar bade sekhar bade is offline
Registered User
 
Join Date: Nov 2009
Posts: 9
Problem in finding the file in sqllib (link directory)

Hi

We are having a filesystem like:

$cd /home/db9inst1
$ls -lrt

lrwxrwxrwx 1 db9inst1 db9inst1 12 Nov 09 2008 sqllib -> /sqllibinst9

I need to check whether db2profile file exists in sqllib directory but actually the sqllib is not a directory it is a link (pointer).

The below statement is displaying "db2profile not found" can anyone help to change the if statement to check whether the file (db2profile) exists or not.

if [ -e /home/db9inst1/sqllib/db2profile ]; then
echo "db2profile exists"
else
echo "db2profile not found"
fi
Reply With Quote
  #2 (permalink)  
Old 12-16-09, 13:44
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Seems to work for me:

bkogan@panipuri /home/bkogan > ls -ld /home/bkogan/testln
lrwxrwxrwx 1 bkogan build 4 Dec 16 13:32 /home/bkogan/testln -> test

bkogan@panipuri /home/bkogan > ls -l /home/bkogan/testln/*
-rw-r--r-- 1 bkogan build 0 Dec 16 13:32 /home/bkogan/testln/testf


bkogan@panipuri /home/bkogan > more testlink
if [ -e /home/bkogan/testln/testf ]; then
echo "db2profile exists"
else
echo "db2profile not found"
fi

bkogan@panipuri /home/bkogan > ./testlink
db2profile exists
Reply With Quote
  #3 (permalink)  
Old 12-17-09, 07:38
sekhar bade sekhar bade is offline
Registered User
 
Join Date: Nov 2009
Posts: 9
Bella Thanks for your reply.

I'm trying to display the list of the databases in all the instances in a server using the below script, so i'm first trying to get the list of all the instances in the server (without using db2ilist) but the databases of the symbolic link instances are not being displayed. Please help.

cd /home
ls -d db* > /tmp/instance.list
while read line
do
if [ -e /home/$line/sqllib/db2profile ]; then
. /home/$line/sqllib/db2profile
fi
export DB2INSTANCE=$line
db2 "list db directory" | grep -p Indirect | egrep -i -e "Database name" >> /tmp/DBNAME.list
done </tmp/instance.list
Reply With Quote
  #4 (permalink)  
Old 12-17-09, 08:48
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What is wrong with using db2ilist? Second, there is nothing written in stone that an instance must reside under the /home directory.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On