Extract Oracle home from Oratab and compare values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract Oracle home from Oratab and compare values
# 1  
Old 09-15-2015
Question Extract Oracle home from Oratab and compare values

Friends,

I'm trying to do below in ksh script, while requesting user to provide src_db and dest_db values
1. Extract src_db and dest_db Oracle home from oratab file
2. Don't find db if it starts with comment (#)
3. Compare both values
4. Message success or exit with error if they don't match

Code:
Variables
=======
src_db = $2
dest_db = $4
oratab= /etc/oratab

Runtime
======
./compare_db src_db db1 dest_db db2

Output
=====
db1 = /oracle/app/oracle/product/11.2.0.3
db2 = /oracle/app/oracle/product/11.2.0.3
Success

I tried using sed from one of the other thread but not able to fit into my requirement,
any ideas or is it even possible?

Thanks.

Last edited by homer4all; 09-15-2015 at 07:06 PM.. Reason: added oratab destination
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

New Oracle Home

How do I set ORACLE_HOME location? When I type echo $$ORACLE_HOME it gives me /u01/app/oracle//product/10.2.0/dbhome_1 which has been deleted. I just installed Oracle 11g and this is supposed to be a new oracle home /u01/app/oracle/product/11.2.0/dbhome_1 Any help from the community... (21 Replies)
Discussion started by: newborndba
21 Replies

2. Solaris

Oracle Solaris 11 on home server

I am interested in learning oracle solais 11 but I can't seem to find a discounted version/free version with security updates for home use (I would like to set it up as I would a real server for practice so I would like to get security updates I understand that there is a trial version but you... (3 Replies)
Discussion started by: crookedmaze
3 Replies

3. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

4. Shell Programming and Scripting

how to change ORACLE HOME?

All, I have to change my ORACLE_HOME in the prodution environment. I have chaged it in .profile file but when I am typing the command bash-2.05$ echo $ORACLE_HOME /apps/oracle/product/10.2.0.4.2011Q1 Instead of Q1 it should show Q3 bcoz I have changed it in .profile file. But at the same... (2 Replies)
Discussion started by: Oracle_User
2 Replies

5. Solaris

Home Directory for oracle user

Hello all, I am Installing Oracle 11g on my Solaris OS. I created the below oracle user: # /usr/sbin/useradd -g oinstall -G dba oracle but when i am trying to to su - oracle it give me the below error No directory Do i have to setup a home directory for oracle user? and how can i do... (1 Reply)
Discussion started by: beayni33
1 Replies

6. UNIX and Linux Applications

Setting up Oracle RAC at home

Hello, I'm planning to set up Oracle 10g RAC at home. I was initaillay planning to get a windows desktop and install Cent OS after wiping out the existing windows OS. I have some questions with regards to this. 1) For setting up RAC, I would have to install an additional NIC besides the one... (2 Replies)
Discussion started by: luft
2 Replies

7. Shell Programming and Scripting

extract DB version from oratab

My oratab has the following contents RMD10203:/u01/app/oracle/product/10.2.0RMD10203:Y RMDIDEVL:/u01/app/oracle/product/11.1.0RMDIDEVL:Y RMDIDES:/u01/app/oracle/product/11.1.0RMDIDES:Y I have a script for which I pass the oracle sid as the parameter I need to extract the version of the... (6 Replies)
Discussion started by: dbins01
6 Replies

8. Shell Programming and Scripting

I need to extract last column of a file and compare the values

Hi, I am new to unix and I need help in solving below mentioned issue, really appreciate ur help. I have a file sam, john, 2324, 07142007 tom, thomson, 2343, 07142007 john, scott, 2478, 07142007 its a comma delimited file, I need to extract the last column from each line and this... (4 Replies)
Discussion started by: vukkusila
4 Replies

9. Shell Programming and Scripting

setting Oracle Home

Hi, if i set Oracle home in the command line as export ORACLE_HOME=/usr/oracle/product/9.2.0; and then checking it by typing echo $ORACLE_HOME,its getting the correct result.But if i try setting the ORACLE_HOME from a shell script by just including the same line as above,it was... (3 Replies)
Discussion started by: DILEEP410
3 Replies

10. Shell Programming and Scripting

How best to extract the users home from /etc/password

What would be the best way to extract a users home from /etc/passwd. I intended to use cut but have been semi advised that a can do it using and eval statement and the ~ operator. Unfortunately this was just a casual conversation so made little sense at the time. Any help much appreciated. cheers (4 Replies)
Discussion started by: spaceship
4 Replies
Login or Register to Ask a Question