I have two shell scripts Caller and getGlobalParameters. There is a function defined in the getGlobalParameters script which calls a java class and uses the values returned by the java class to set the environment variables. Once the call to the getGlobalParameters completes, the caller is trying to use the environment variables set by the getGlobalParameters. The issue I am facing is the environment variables set by the getGlobalParameters are not accessible to the Caller. Below is the code snippet of Caller and getGlobalParameters.
Caller.sh
GETGLOBALPARAMETERS=getGlobalParameters.sh
jobName=ABC
JOBENV=TEST
eval '$GETGLOBALPARAMETERS $jobName $JOBENV'
printenv
#In the printenv statement above I am not seeing the environment variables set by the getGlobalParameters
getGlobalParameters.sh -
#Sample OUTPUT value a^1$b^2
IFS='$' read -r -a array <<< "$OUTPUT"
declare -A configkeys
for element in "${array[@]}"
do
IFS='^' read -r -a temparray <<< "$element"
configkeys[${temparray[0]}]=${temparray[1]}
done
for key in "${!configkeys[@]}"; do
export "${key}="${configkeys[$key]}""
done
printenv
#In the above printenv I am able to see the environment variables.
Can anyone take a look and let me know what I am missing. Have spent a day already figuring out the issue, but couldn't find any way to fix this.
getGlobalParameters.sh -
is not a line insideCaller.sh
, right? It is supposed to be a headline indicating the code below belongs togetGlobalParameters.sh
, right? Two separate files, two separate code snippets. I can fix the formatting of the question, but please confirm I understand what you wanted to post.