0

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?

2
  • don't know why this question is voted down.. please give reason as well if you are voting down .. Commented Mar 27, 2012 at 11:25
  • 1
    Edit the question and show us what you've tried. Commented Mar 27, 2012 at 11:46

3 Answers 3

3

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/
Sign up to request clarification or add additional context in comments.

11 Comments

is there any possibility to execute and set this export command in profile file via a script?
you can just add that line to your .profile or .bash_rc or .bash_profile (depends on your shell) in your home directory. profile is user specific, so you don't have to worry about being there. As long as no one else can the location where you kept the binary, you don't have to worry about this.
no this type of setup I have to give in script .. for profile folder whether i have to take folder path from any system variable .. or whether it is static in the folder and I can just open and append the .profile file?
it is showing that sch is not found in my machine .. am I suppose to export from any folder this command .. please tell me that folder path if you know ..
it's shc. If it's not there then you can download from internet and install it for linux. You can just run 'export' from anywhere. Once you created the "myscript.sh.x" you just need to add its path to PATH variable.
|
2

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.