IMAGE=$imgvalue;
if [ $imgvalue :=1 ]
then
echo DO=ABC;
elif [ $imgvalue :=2 ]
then echo DO=ETC;
elif [ $imgvalue :=3 ]
then echo DO=XYZ;
else
echo "$imgvalue is unsupported";
exit 1;
fi
in above script IMAGE=1 , IMAGE=2, IMAGE=3 whatever may be the value i have assigned it's showing only DO=ABC other conditions not working . any one pls check.
i have tried all possibilities and solutions mentioned above . it's not working .
can any one help the make script coding with the above requirement.only in below senario it's working and displaying DO=ABC for all inputs like IMAGE=1 or IMAGE=2 or IMAGE=3
IMAGE=$imgvalue;
if [ $imgvalue =:1 ]
then
echo DO=ABC;
elif [ $imgvalue =:2 ]
then
echo DO=ETC;
elif [ $imgvalue =:3 ]
then
echo DO=XYZ;
else
echo "$imgvalue is unsupported";
exit 1;
fi
firstly we must get the IMAGE value and its represented to $3
so $3="IMAGE=2"
and we must cut the value from IMAGE express with `imgvalue=${3/*=/}`
then imgvalue equals to 2..then go to if-elif..
try this...
imgvalue=${3/*=/}
if [ $imgvalue = 1 ]
then
echo DO=ABC;
elif [ $imgvalue = 2 ]
then
echo DO=ETC;
elif [ $imgvalue = 3 ]
then
echo DO=XYZ;
else
echo "$imgvalue is unsupported";
exit 1;
fi