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 Answer
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.