Sponsored Content
Top Forums Shell Programming and Scripting Switch from one database to other using shell script Post 302437996 by sachinkl on Saturday 17th of July 2010 06:21:50 AM
Old 07-17-2010
Switch from one database to other using shell script

Hi all,

This is my first ever post to any forum so, dont let this go in vain...........Smilie

Here is the scenario........

I have logged into the unix where oracle_sid is initialized for some X database in the .profile.
I have a unix script where some sql query which fetches data from X database.

Now, i need to connect to some other database say Y, I have set the ORACLE_SID to point to Y. But, when i try to connect to that database i get the following error "ORA-12154: TNS:could not resolve service name".

Here is the code that i am using:
Code:
ORACLE_SID = “X” ;      export  ORACLE_SID    
ORAENV_ASK="NO"
 
. /opt/bin/oraenv
. /var/opt/oracle/<abc>/$ORACLE_SID/<xyz>
 
<some sql queries............................>       #successfull
 
ORACLE_SID = “Y”;     export  ORACLE_SID   #switching database
ORAENV_ASK="NO"
 
. /opt/bin/oraenv
. /var/opt/oracle/<abc>/$ORACLE_SID/<xyz>      
 
<some sql queries............................>      #Here i am getting connection failed

Any help would be appreciated.....

Last edited by Franklin52; 07-17-2010 at 07:58 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script: want to insert values in database when update script runs

Hi , I am new to linux and also also to shell scripting. I have one shell script which unpacks .tgz file and install software on machine. When this script runs I want to insert id,filename,description(which will be in readme file),log(which will be in log file) and name of unpacked folder... (1 Reply)
Discussion started by: ring
1 Replies

2. Shell Programming and Scripting

Connection to database through shell script

Hi when i am calling the shell script with two parameter like id and date it works fine.But the same shell script is call by java application it gives the error as shown below Thu Jan 8 04:13:22 EST 2009|The Get Segment Process Failed: SP2-0306: Invalid option. Usage: CONN where <logon>... (1 Reply)
Discussion started by: ravi214u
1 Replies

3. Programming

Need help on Shell script for database maintainace..

Hi All, I have to perform some tasks for database maintainace. I am using postgresql on RHEL 4.4. 1) I have to run "vacuumedb" on the database as postgres user. 2) I have to reindex the database as postgres user. Now i want to write shell script to do these tasks one... (3 Replies)
Discussion started by: ashokkumar.p
3 Replies

4. Shell Programming and Scripting

Switch User in within a Shell Script

Hi Experts, I'm trying to write a shell script to stop few things where i have to use another user to execute a command. Otherwise it will not work. Your help is really appreciated Thanks, (16 Replies)
Discussion started by: Afi_Linux
16 Replies

5. Shell Programming and Scripting

Switch user inside shell script

Hi, I am trying to create one script where I have to login as another user inside the script to exeute some commands How can i achieve this? Many thanks in advance. (4 Replies)
Discussion started by: prarat
4 Replies

6. Shell Programming and Scripting

How to switch user using shell script ?

Hi, script1.sh script2.sh script3.sh From above, script1.sh is the main script which is executed from root user, creates installation directory, changing ownership and execution rights etc..etc.. and finally calls scripot2.sh and script3.sh to create the database as well as for post... (1 Reply)
Discussion started by: milink
1 Replies

7. UNIX for Advanced & Expert Users

Help with server switch shell script

I need a script to change server automatically after performing some operations. The command for changing server is ssh username@servername . Then a prompt comes to enter a password. Then i need to perform some opertaions on the other server. How can i do this in a script? (1 Reply)
Discussion started by: pratikm23
1 Replies

8. UNIX for Dummies Questions & Answers

How to switch the user before executing a shell script from web page??

hi, i want to execute a shell script as a different user. the flow is like this. there is a html web page from which i have to call a shell script. web server is apache. to call the shell script from html page, a perl script is required. so the html page calls the perl script and the perl... (2 Replies)
Discussion started by: Little
2 Replies

9. Shell Programming and Scripting

Shell Script for Java version switch

Hello all I am writing a shell script for unix, and I am trying to get it to ask me if instances are stopped, and then if the version of java running is correct, if not I want it to ask me to switch to the other bit version. I am newish to shell and not clear on how to to input prompts for yes/no... (3 Replies)
Discussion started by: bigbenn
3 Replies

10. UNIX for Beginners Questions & Answers

How to switch user in shell script?

HI in a server we can't login with root user directly but i can login with different user and then i can switch to root user by su command Requirement is there anyway where i can write a script without mentioning password in file as mentioning the root password is not the... (3 Replies)
Discussion started by: scriptor
3 Replies
ocs(1)							      General Commands Manual							    ocs(1)

NAME
ocs - creates and maintains the database for cscope on a recursive directory set SYNOPSIS
ocs [-x] [-f] [-q] [-u] DESCRIPTION
This manual page briefly documents ocs , a shell script wrapper that automates the creation and maintenance of a cscope(1) database on a recursive set of directories. Under normal circumstances, ocs generates a cscope database on a recursive group of directories starting from the current working directory, before launching cscope(1) in interactive mode. OPTIONS
-x Enable debugging. -f Force. Do not ask about regenerating 'TMP' lists (lists generated by ocs ), just do it; Allow the regeneration of 'CSD' (lists gen- erated by cscope(1) ) lists. -q Tell cscope to build a fast reverse index. Database disk space usage is doubled, but searching speed is increased. -u Request that the database be updated or regenerated. FILES
./cscope.rc If this is an executable shell script, it will be included in the body of ocs in order to override intenal filenames and other options. See the comments at the top of /usr/bin/ocs for more information. BUGS
None noted. SEE ALSO
cscope(1), /usr/bin/ocs. AUTHORS
This manpage originally prepared by Nick Rusnov <nick@grawk.net> for the Debian Project. The Debian Project June 2001 ocs(1)
All times are GMT -4. The time now is 02:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy