1

i have to write a bash script wherein i need to connect with oracle database and perform some queries. `sqlplus $DB_USER/$DB_PASSWORD' These variables are stored in another file "rangerenv.sh" How do i use these variables in another bash file?

1
  • 1
    Add rangerenv.sh to your question. Commented Jun 19, 2019 at 8:41

1 Answer 1

2

You could extract those values into a separate config file that both scripts can access. Your script can use source load the variables from this file.

config file

DB_USER="user"
DB_PASSWORD="password"

your script

source config
sqlplus $DB_USER/$DB_PASSWORD

Be careful mixing sensitive variables with your code as they can end up in source control, backups or other places where they may be exposed to malicious actors. If these credentials exist in multiple files it can be difficult to rotate them and keep your database secure.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.