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

 
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
#!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.

if it is not asked, then it means, the ORACLE_HOME is having the value.

 
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.

1 Like

Thanks..

What is code tag?

I could not access the url for code tag.

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

It is blocked here.

What about:

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

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.

1 Like