Reputation: 3342
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
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
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:
Upvotes: 1