chanikya
asked on
connect to the Oracle database using shell script
Hi Experts,
I am new to shell script.
In the shell script i have the below statement.
sqlplus / @connectstring << EOF
.... some statements
EOF
When I am trying to execute the shell script, it is asking me username and password.
But as per my requirement it should not ask the username and password and also i should not hard code username and password in the shell script.
what else i need to do, to make use of the same statement without any changes.
your suggestions will be highly appreciated.
Thanks In Advance .
Thanks,
Chanikya.
I am new to shell script.
In the shell script i have the below statement.
sqlplus / @connectstring << EOF
.... some statements
EOF
When I am trying to execute the shell script, it is asking me username and password.
But as per my requirement it should not ask the username and password and also i should not hard code username and password in the shell script.
what else i need to do, to make use of the same statement without any changes.
your suggestions will be highly appreciated.
Thanks In Advance .
Thanks,
Chanikya.
I have to assume you have already set up OS authentication and the ORACLE variables set in the script.
Remove the space before the @:
sqlplus /@connectstring << EOF
.... some statements
EOF
Remove the space before the @:
sqlplus /@connectstring << EOF
.... some statements
EOF
>>should be creating 2 files, for more clarity
Not necessary in UNIX. 'Here' scripts are common. In my opinion 2 files makes it more confusing.
Not necessary in UNIX. 'Here' scripts are common. In my opinion 2 files makes it more confusing.
I won't think you can able to login without hard coding the user name and password.
Oracle has to know what crediential as to be logged in.
Oracle has to know what crediential as to be logged in.
>>I won't think you can able to login without hard coding the user name and password
Look up OS Authentication:
http://www.oracle-base.com/articles/misc/OsAuthentication.php
Look up OS Authentication:
http://www.oracle-base.com/articles/misc/OsAuthentication.php
Sorry, did not see your requirement for not hardcode the user and password.
In this case, you only need to pass as parameters for your shell script.
Then, it would be like this:
user=$1
passwd=$2
sqlplus $user/$passwd@connectionst ring @file_name.sql
In this case, you only need to pass as parameters for your shell script.
Then, it would be like this:
user=$1
passwd=$2
sqlplus $user/$passwd@connectionst
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, I agree. But he is asking a question around shell script.
The answer was presented here, not only by me, in a few variants.
That said, what you have recommended goes beyond that and is correct, but it is not in the scope of his question.
The answer was presented here, not only by me, in a few variants.
That said, what you have recommended goes beyond that and is correct, but it is not in the scope of his question.
The question centers around using OS Authentication not how to not use OS authentication.
I'll use my right of not agree, as the title of this question is very precise and in the question itself, OS authentication is not mentioned.
This topic was introduced by your assumptions...
But enough of that. In any way, the user has information enough to make his script to work properly.
This topic was introduced by your assumptions...
But enough of that. In any way, the user has information enough to make his script to work properly.
>>sqlplus / @connectstring << EOF
This is OS authentication. I did not 'assume'.
This is OS authentication. I did not 'assume'.
ASKER
I would like to know, whether it is possible with os authentication or not.. I got the answer.
sqlplus $username/$password@connec t , I got this in many forums..
Thanks a lot guys for your contribution.
Thanks,
Chanikya.
sqlplus $username/$password@connec
Thanks a lot guys for your contribution.
Thanks,
Chanikya.
my understand is that you should be creating 2 files, for more clarity:
1) a file with all your SQL statements. You can save it with extension .sql
2) shell script.
The shell script will have the following command line:
sqlplus <user>/<password>@connecti
And that's it.