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 > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > If clause failin in script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-17-08, 10:33
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
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 10:39.
Reply With Quote
  #2 (permalink)  
Old 01-17-08, 10:36
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Can some body can help me please
Reply With Quote
  #3 (permalink)  
Old 01-17-08, 18:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #4 (permalink)  
Old 01-18-08, 12:00
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
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 12:16.
Reply With Quote
  #5 (permalink)  
Old 01-18-08, 12:24
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
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
Reply With Quote
  #6 (permalink)  
Old 01-18-08, 12:26
smith43017 smith43017 is offline
Registered User
 
Join Date: Sep 2006
Posts: 92
Thank you very much Stolze
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