How the user will provide the parameters for Oracle db connection in a shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How the user will provide the parameters for Oracle db connection in a shell script?
# 1  
Old 03-09-2012
How the user will provide the parameters for Oracle db connection in a shell script?

I'm new into unix.

My question: is possible to write a shell script which will ask for the
ORACLE_HOME, ORACLE_SID, USERNAME, PASSWORD to connect to Oracle db.

In generally we have to set the ORACLE_HOME in .profile file. And after putting the 'sqlplus' command it asks for the username & password for db connection.

plz share your ideas.

Thanks,
Priya
# 2  
Old 03-09-2012
Code:
 
if [ -z $ORACLE_HOME ] # True if  the  length  of  string string is zero
then
  echo "Enter the value of ORACLE_HOME"
  read ORACLE_HOME
  export $ORACLE_HOME
fi

# 3  
Old 03-09-2012
Code:
#!bin/sh
if [ -z $ORACLE_HOME ] # True if  the  length  of string is zero
then
  echo "Enter the value of ORACLE_HOME"
  read ORACLE_HOME
  export $ORACLE_HOME
fi


here is my script but it didn't ask me for the ORACLE_HOME.

Last edited by Franklin52; 03-09-2012 at 05:49 AM.. Reason: Please use code tags for data and code samples, thank you
# 4  
Old 03-09-2012
if it is not asked, then it means, the ORACLE_HOME is having the value.

Code:
 
if [ -z $ORACLE_HOME ] # True if  the  length  of  string string is zero
then
  echo "Enter the value of ORACLE_HOME"
  read ORACLE_HOME
  export $ORACLE_HOME
else
 echo "ORACLE_HOME has the value of $ORACLE_HOME"
fi

use code tags while posting the script and data.

https://www.unix.com/how-post-unix-li...code-tags.html
This User Gave Thanks to itkamaraj For This Post:
# 5  
Old 03-13-2012
Thanks..

What is code tag?

I could not access the url for code tag.

https://www.unix.com/how-post-unix-li...code-tags.html

It is blocked here.
# 6  
Old 03-13-2012
What about:
https://www.unix.com/how-post-unix-li...code-tags.html

---
I had a look at the link in post #4... It works...

Last edited by vbe; 03-13-2012 at 07:26 AM.. Reason: addendum
# 7  
Old 03-13-2012
The link itkamaraj posted works. Yours doesn't because you used the shortened version. If Youtube is blocked, here's the description of the tag.
This User Gave Thanks to pludi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script verify connection to Oracle if not successful

i have a script that connects to the oracle database and executes the query statements. it works fine and i would like to add some message to check if the connection to oracle is not successful. basically this is the code snippet: #!/bin/sh ... ... ... sqlplus -s username/password@dbName... (2 Replies)
Discussion started by: wtolentino
2 Replies

2. UNIX for Dummies Questions & Answers

How to fix connection to Oracle database through shell script?

I have a question regarding how to connect to Oracle Database through shell script. 1. If I want call a stored procedure on Linux server as this, it works. $sqlplus /nolog SQL*Plus: Release 12.1.0.2.0 Production on Fri Jun 12 14:49:49 2015 Copyright (c) 1982, 2014, Oracle. All rights... (2 Replies)
Discussion started by: duke0001
2 Replies

3. Shell Programming and Scripting

How to setup Oracle connection inside shell script?

Hi, We have Oracle Connection parameters set up in file name "TESTDB" at location /abc/etc.When I try to run my shell script it does not connect to Oracle database. Please let me know how "TESTDB" file can be called inside script. ####################### Setting the directories... (2 Replies)
Discussion started by: sandy162
2 Replies

4. Shell Programming and Scripting

Verifying oracle connection from shell script

Hi, Oracle 9.2 Solaris 10 From the shell script ........How can we verify whether oracle connection is successful or not ? Shell script will prompt the user to enter the oracle schema username, password and tns name. So, *how to verify whether oracle connection has been established or... (14 Replies)
Discussion started by: milink
14 Replies

5. Shell Programming and Scripting

Creating oracle user and giving him grants using shell script

Hi , I want to write a shell script that can create oracle database user and grants permission to this user. Thanks & Regards, Deepak (4 Replies)
Discussion started by: Deepakjha
4 Replies

6. Shell Programming and Scripting

oracle connection from shell script

Hi, For connecting to oracle my script is using the command sqlplus username/password@db_instance_name.For this to work i am setting ORACLE_HOME,TNS_ADMIN and ORACLE_SID in a seperate script.My question is,could we make a connection to oracle just by the command sqlplus... (4 Replies)
Discussion started by: DILEEP410
4 Replies

7. Shell Programming and Scripting

Help in Shell scripting to modify the User Creation script in oracle database.

Hi, I have several users to create on my test Oracle database taking the scripts from the Production Oracle database. I have a separate text file where I have user-id and passwords maintained. I need help in writing a shell script to go thru the user creation scripts and replace VALUES... (1 Reply)
Discussion started by: rparavastu
1 Replies

8. Shell Programming and Scripting

provide a user password from a script

Hi all, passwd <username> < /var/adm/passwd.txt cat /var/adm/passwd.txt abcd1234 abcd1234 when I run this from the script, it comes with: New password: It is not able to pick from the location /var/adm/passwd.txt. thanks in advance. (6 Replies)
Discussion started by: solaix14
6 Replies

9. Shell Programming and Scripting

passing oracle parameters back to Shell

Hi All, Does anyone have any solutions for passing back multiple variables back to the SHELL from a call to an ORACLE procedure: eg #username='scott' #password='tiger' #database='orcl' username='ITGCD03D03' password='tC5epIew' database='ITGCD03D' sqlplus -s... (4 Replies)
Discussion started by: satnamx
4 Replies

10. Shell Programming and Scripting

shell script- oracle connection problem

Hi all, I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the... (4 Replies)
Discussion started by: nattynatty
4 Replies
Login or Register to Ask a Question