Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Posts
    97

    Unanswered: If clause failin in script

    if [ ${dbfile}='DBPTLFEP'||${dbfile}='DBPTLLMP']; then
    db2 deactivate db ${dbfile}
    fi


    I want to deactivate db if name are DBPTLLMP,DBPTLFEP the vales I am reading from flat file.
    Last edited by smith43017; 01-17-08 at 11:39.

  2. #2
    Join Date
    Sep 2006
    Posts
    97
    Can some body can help me please

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You are not using the correct syntax for conditions. Or-ing two conditions is done with -o. Furthermore, you should consider the case where $dbfile could be the empty string - this would result in "if [ ='...' ]; then", which is invalid syntax. Try this instead:
    Code:
    if [ "${dbfile}" = 'DBPTLFEP' -o "${dbfile}" = 'DBPTLLMP' ]; then
        db2 deactivate ${dbfile}
    fi
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Sep 2006
    Posts
    97
    Actuvally $dbfile doesn't have any empty string.

    It have 7 line (no extra spaces)
    each line one databse name. But thanks for adive in another post about reading man on test.

    I will try this and let you guys jknow about it
    Last edited by smith43017; 01-18-08 at 13:16.

  5. #5
    Join Date
    Sep 2006
    Posts
    97
    HTML Code:
    db2 list db directory|grep -p Indirect|grep -E "alias"|cut -c41-49>dbs
    while read dbfile
    do
    if [ "${dbfile}" = 'DBPTLFEU' -o "${dbfile}" = 'DBPTLLMU' ]; then
        db2 deactivate db ${dbfile};
    else
     db2 connect to ${dbfile};
     echo ${dbfile} 
     db2 -tvf ptldeadevnt.sql 
     db2 connect reset>/dev/null
    fi
    done < dbs

  6. #6
    Join Date
    Sep 2006
    Posts
    97
    Thank you very much Stolze

Posting Permissions

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