Connecting to multiple oracle databases from unix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nunrgleo
    New Member
    • Feb 2008
    • 1

    Connecting to multiple oracle databases from unix

    Hi all,
    I need to write a script that logs into several oracle databases in a sequential manner from a unix box using different login and password e.g sqlplus found/duckl@dnd007 and many more databases to check the logon details work and database is up. At the moment i've got it all hardcoded in a script e.g
    echo 'testing xxx'
    sqlplus xxx/yyy@xxx
    .
    .
    .
    echo 'testing aaa'
    sqlplus aa/yyy@aaa

    but the problem is i have to type exit at the sqlplus prompt all the time and this can be pretty boring as i've got a long list.
    Thanks for the help.
    Cheers.
  • osuri
    New Member
    • Feb 2008
    • 3

    #2
    Here is the code (I put it in a script called check_mult_db_s tatus.sh) that you are looking for:
    Code:
    echo Testing db1
    sqlplus -s u1/p1@db1<< EOF
    quit
    EOF
    echo Testing non-existent db2
    sqlplus -s u2/p2@db2<< EOF
    quit
    EOF
    echo Testing db1
    sqlplus -s u1/p1@db1<< EOF
    quit
    EOF
    When you execute this script, you will see less visual noise (as a result of the -s parameter) and will still see errors at the appropriate place, as you will see below in the execution dialog:

    $ ./check_mult_db_s tatus.sh
    Testing db1
    Testing non-existent db2
    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified



    ERROR:
    ORA-01005: null password given; logon denied


    Testing db1
    $

    Comment

    Working...