Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655

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

    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

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    if [ -x /opt/db2inst1/sqllib/db2profilet ]
    then
        /opt/db2inst1/sqllib/db2profilet
    else
       echo program not found
    fi

  3. #3
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    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

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Have you considered sub contracting. <raises hand>

  5. #5
    Join Date
    Sep 2008
    Location
    Toronto,Canada
    Posts
    655
    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.

  6. #6
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Sent you an email.

Posting Permissions

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