How to include a file containing variables in a shell script

I have many script shells and I want to include a file containing variables in this shell

script?

My var script:

################################################################################### ORACLE_LOGIN=login ORACLE_PWD=pwd CHEMIN_1="/home/" CHEMIN_2="/scripts/" LOG_FILE="$CHEMIN_1/max.log" export ORACLE_SID=oracle_sid ################################################################################### 

My script sh:

 #!/bin/ksh #set -x # ============== LOAD VAR HERE ==================================== ???? ################################################################## #### Begin #### ################################################################## write "Begin $0" $ORACLE_HOME/bin/sqlplus -s $ORACLE_LOGIN/ $ORACLE_PWD@ $ORACLE_SID <<EOF >> $LOG_FILE 2>&1 @$CHEMIN_2/sp_rep_alim_dia_date_max.sql exit EOF write "End." 

thanks.

+7
linux bash sh
source share
4 answers

It depends on the shell, but one of these two usually works:

 . var 

or

 source var 

I'm not sure about ksh, but I would suggest that both will work.

+12
source share
 . ./name_of_the_var_script 

Thats dot + space + dot + slash + filename (because the dot utility needs an absolute or relative path to your var script).

+3
source share

use the command . (dot) to indicate a file

 . var_script 
+1
source share

source var worked for me. this link Passing all variables from one shellscript to another? has a good explanation for this problem

// Hope this helps.

0
source share

All Articles