I recently added a variable to a script process that will be used as a replacement value via sed for an output script (not bash). This is one of many variables set within an if statement and (for reasons I cannot seem to deduce) the variable loses its value once outside of the if statement. This is not occurring with any of the other variables that are set within the if statement. Code and expanded results follow.
if [ ${ModeTyp} == "P" ] ; then
PC_DB=idpacleanelig
PS2_DB=idpaprodserv2
PV_DB=idpaprodviews
PV_OUT=idpaprodviews
P_DB=idpaprod
P_DBIN=idpaprod
CERNH="CE_RunHierarchyControl_T" |
CECONTROL=CE_LegacyControlTable_RHMv5
echo "CERNH value is ${CERNH} after Default Population in if prod statement"
else
PC_DB=hfsdevsandbox
PS2_DB=hfsdevsandbox
PV_DB=idpaprodviews
PV_OUT=hfsdevsandbox
P_DB=hfsdevsandbox
P_DBIN=idpaprod
CERNH="CE_RunHierarchyControl_T" |
CECONTROL=CE_LegacyControlTable_RHMv5
GOTOLBL_1=""
GOTOLBL_3=""
echo "CERNH value is ${CERNH} after Default Population in if test statement"
fi
echo "CERNH value is ${CERNH} after Default Population"
RUN RESULTS:
+ '[' T == P ']'
+ PC_DB=hfsdevsandbox
+ PS2_DB=hfsdevsandbox
+ PV_DB=idpaprodviews
+ PV_OUT=hfsdevsandbox
+ P_DB=hfsdevsandbox
+ P_DBIN=idpaprod
+ CECONTROL=CE_LegacyControlTable_RHMv5
+ CERNH=CE_RunHierarchyControl_T
+ GOTOLBL_1=
+ GOTOLBL_3=
+ echo 'CERNH value is CE_RunHierarchyControl_T after Default Population in if test statement'
CERNH value is CE_RunHierarchyControl_T after Default Population in if test statement
+ echo 'CERNH value is after Default Population'
CERNH value is after Default Population
Asked by Raymond Meyer
(1 rep)
Oct 8, 2024, 01:36 PM
Last activity: Oct 8, 2024, 01:38 PM
Last activity: Oct 8, 2024, 01:38 PM