Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    9

    Unanswered: 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

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,368
    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

  3. #3
    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

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    What is wrong with using db2ilist? Second, there is nothing written in stone that an instance must reside under the /home directory.

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •