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 > Prevent KSH script from abort - how ??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-11, 13:53
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Prevent KSH script from abort - how ??

Hello All,


can someone help me some flag or command for KSH shell to keep script running after 'not found' error.

For example I have a command like below

Code:
log_today "Trying db2profile . . . "

. $dbmsprofile

if [[ $? -eq 0 ]]; then 
   echo "Success" >>$today_file 
  else
echo "Failed" >>$today_file
fi
Now in testing I pointed $dbmsprofile to non existing script file. The script terminates with the error :

Quote:
main[76]: /opt/db2inst1/sqllib/db2profilet: not found.
Please help me with some idea how do we avoid the termination of the script.

Regards
DBFinder
Reply With Quote
  #2 (permalink)  
Old 10-13-11, 20:05
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Code:
if [ -x /opt/db2inst1/sqllib/db2profilet ]
then
    /opt/db2inst1/sqllib/db2profilet
else
   echo program not found
fi
Reply With Quote
  #3 (permalink)  
Old 10-13-11, 20:18
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Thanks for response. Already running like that. Still I do not like it.

Code:
if [[ -s $dbmsprofile ]]; then 
    . $dbmsprofile
if [[ $? -eq 0 ]]; then 
echo "Success" >>$today_file 
else
echo "Failed" >>$today_file
print "Error: DB profile could not be loaded\nDatabase : $db_name\nInstance : $db_inst\n" >alert.msg
send_alert sgill.dba@gmail.com alert.msg
fi
else 
echo "not found" >>$today_file
print "Error: DB profile could not be found\nDatabase : $db_name\nInstance : $db_inst\n" >alert.msg
send_alert sgill.dba@gmail.com alert.msg
	
fi
Definitely there will be numerous others that may fail when my script goes in client's hands.

This way I cannot handle the error effectively. I need the the script to continue even after the command fails.


Thanks for the response anyways.

Regards
DBFinder
Reply With Quote
  #4 (permalink)  
Old 10-14-11, 11:10
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Have you considered sub contracting. <raises hand>
Reply With Quote
  #5 (permalink)  
Old 10-15-11, 06:54
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Quote:
Originally Posted by kitaman View Post
Have you considered sub contracting. <raises hand>
Funny ! I was thinking of sub scripting !! my bad.

For sub contracting you have to quote ; how much ; then I may think about it. May be I transfer whole thing if good quote or none.
Reply With Quote
  #6 (permalink)  
Old 10-15-11, 09:21
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Sent you an email.
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