Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    3

    Red face Unanswered: Error handling in unix

    hi,

    i want to know is there any command to handle error if any exception occur while connecting db from ksh shell script.
    for eg
    if i connect to a db
    sqplus -s user/pass@db through ksh shell scripting if i give wrong password it will give oracle error which needs to be handled in shell scripting, kindly guide me on this
    oracle db version : 10g

  2. #2
    Join Date
    May 2012
    Posts
    3
    Guys... help me on this....

  3. #3
    Join Date
    Mar 2010
    Location
    Vienna, Austria
    Posts
    149
    Just substitute the "echo" commands in the code below with your shell-scripts:

    sql - script:
    Code:
    whenever sqlerror exit failure
    connect test/wrong_pwd
    exit success
    shell script:
    Code:
    sqlplus -s test/test @test.sql
    if [ $? -eq 0 ]
      then echo NO ERROR
      else echo ERROR OCCURED
    fi
    Tested on SuSE Linux with Oracle 11gR2, but should work on any Oracle Version under any Unix/Linux
    "There is always an easy solution to every problem - neat, plausible, and wrong."
    -- H.L. Mencken

Tags for this Thread

Posting Permissions

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