Article 55G6M Reading a value from a ini, compare and execute

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?latest?d=yIl2AUoC8zA latest?i=k-8zdsnkfbg:GvqZGlOwdF0:F7zBnMy latest?i=k-8zdsnkfbg:GvqZGlOwdF0:V_sGLiP latest?d=qj6IDK7rITs latest?i=k-8zdsnkfbg:GvqZGlOwdF0:gIN9vFwk-8zdsnkfbg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments