Reading a value from a ini, compare and execute
by AlMeu from LinuxQuestions.org on (#55G6M)
Hi guys
I play in Pocky version with some scripts and I get problem with a very simple structure of "if" to compare a numeric value and execute something and I can't figure out why doesn't want execute correct.
The diag variable takes values 0 or 1.
I have a "system.ini" file where is memorized this numeric value:
Code:[version]
diag=1a library file "common.sh" where are defined common variables:
Code:ModDIAG=$(awk -F "=" '/diag/ {print $2}' $dir/COMUN/Info/system.ini)and in other script "test.sh" I try use this variable for enable some code for debug:
Code:source $dir/scripts/common.sh
echo "ModDiag=$ModDIAG" > /dev/kmsg
if [[ "$ModDIAG" -eq 1 ]]
then
echo "This is a test" > /dev/kmsg
fi
echo "End test" > /dev/kmsgat the end, no mater what condition I put in if, I get always on screen:
Code:ModDiag=1
End testThe reading value is correct but if condition for numeric value doesn't execute.
What I miss?


I play in Pocky version with some scripts and I get problem with a very simple structure of "if" to compare a numeric value and execute something and I can't figure out why doesn't want execute correct.
The diag variable takes values 0 or 1.
I have a "system.ini" file where is memorized this numeric value:
Code:[version]
diag=1a library file "common.sh" where are defined common variables:
Code:ModDIAG=$(awk -F "=" '/diag/ {print $2}' $dir/COMUN/Info/system.ini)and in other script "test.sh" I try use this variable for enable some code for debug:
Code:source $dir/scripts/common.sh
echo "ModDiag=$ModDIAG" > /dev/kmsg
if [[ "$ModDIAG" -eq 1 ]]
then
echo "This is a test" > /dev/kmsg
fi
echo "End test" > /dev/kmsgat the end, no mater what condition I put in if, I get always on screen:
Code:ModDiag=1
End testThe reading value is correct but if condition for numeric value doesn't execute.
What I miss?