By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,683 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,683 IT Pros & Developers. It's quick & easy.

Connecting to multiple oracle databases from unix

P: 1
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.
Feb 20 '08 #1
Share this Question
Share on Google+
1 Reply

P: 3
Here is the code (I put it in a script called that you are looking for:
Expand|Select|Wrap|Line Numbers
  1. echo Testing db1
  2. sqlplus -s u1/p1@db1<< EOF
  3. quit
  4. EOF
  5. echo Testing non-existent db2
  6. sqlplus -s u2/p2@db2<< EOF
  7. quit
  8. EOF
  9. echo Testing db1
  10. sqlplus -s u1/p1@db1<< EOF
  11. quit
  12. 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:

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

ORA-01005: null password given; logon denied

Testing db1
Feb 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.