pratik garg
pratik garg

Reputation: 3342

How do I create a shell script to log in to an oracle database and run a stored procedure

I am trying to create an UNIX command but I'm not sure how to do it.

I want keyword which I can run from any where in the prompt, just like PWD, CD etc. that will log in to an Oracle database from a Unix shell script to run a procedure in the database.

My biggest problem is that I want to hide database login information in my shell script..

I have tried to create a shell script having one line as follow ..

sqlplus user_name /passwod@database_name

Now I want to turn this into compiled code so that other users won't be able to read my login information as plaintext.

How would I do this on a unix system?

Upvotes: 0

Views: 2080

Answers (3)

P.P
P.P

Reputation: 121417

You can use shc (shell script compiler) to create a binary for your script.

$shc -f myscript.sh

This will create a binary named: myscript.sh.x which will do what you are expecting (hiding logins). But you have to recompile & create the binary everytime you change your passwd or username.

If you want to make it available everywhere then just add it to your PATH variable:

$export PATH=$PATH:/your/binary/location/

Upvotes: 3

beny23
beny23

Reputation: 35048

I'd look into using Oracle Wallet, rather than obfuscation...

Upvotes: 2

l0b0
l0b0

Reputation: 58928

Sounds like you'd like to develop a script to log in to the database with a password and run some commands without user interaction. If the script is on a shared machine, your options boil down to creating a script with the password in plain text, but only readable for you (chmod 700 file.sh). Creating a script with an encrypted/obfuscated password isn't more secure - Someone who has read access to the script can just copy the command.

You could also enable passwordless login:

  • SSH-style, that is, log in to the DB server with a user that is allowed to run queries without a password on the server
  • Some other privilege forwarding
  • White-listing your host

Upvotes: 1

Related Questions