Hello, I went to run a shell script in the terminal but I get an error as if I could not accept the condition in the first one (I already gave him the permissions) the exercise says the following:
Build a Shell Script called lartc.sh that allows you to receive the following parameters and be validated:
lartc -i ethN -r class 1 percentage 1 ... class n percentage n
lartc -i ethN -cln
lartc -i ethN -voip bw
EthN: a number from 0 to 9 to place with the word eth ex. "Eth2"
Class: an 8-bit binary number ex. "01100101"
Percentage: a percentage number eg. "20%" (Between 0 - 100)
Bw: a decimal number (Positive or Negative)
examples:
lartc -i eth0 -r 01101010 39% 01001010 51% 01111010 20%
lartc -i eth6 -voip -2000
lartc -i eth3 -r 00000011 50% 11001100 69%
lartc -i eth9 -cln
and I will leave a screen shot of what I get in console
the $ 1 is lartc and it says lartc = lartc which is true but it does not execute the rest and I do not know why here is the code
#!/bin/bash
numero='^-?[0-9]+([.][0-9]+)?$'
cod='^[01]{8}$'
proc='0*(100|[0-9]{1,2})%$'
if [$1="lartc"] && [$2="-i"]; then
if [$3="eth0"] || [$3="eth1"] || [$3="eth2"] || [$3="eth3"] || [$3="eth4"] || [$3="eth5"] || [$3="eth6"] || [$3="eth7"] || [$3="eth8"] || [$3="eth9"]; then
if [$4="-cln"]; then
if [ -z $5 ]; then
echo correcto
else
echo incorrecto
fi
elif [$4="-voip"]; then
if [$5=~ $numero]; then
echo incorrecto
else
if [ -z $6 ]; then
echo correcto
else
echo incorrecto
fi
fi
elif [$4="-r"]; then
if [ $5 -le 0 ]; then
echo incorrecto
else
for ((num =6; num <=$5+5; num=num+1)) do
cont=0
cont=$num+1
if [${!num}= ~$cod] && [${!cont}= ~$proc]; then
echo incorrecto
else
echo correcto
fi
done
fi
else
echo incorrecto
fi
else
echo incorrecto
fi
else
echo incorrecto!
fi