-3

I have written the code. to check the variable value if it GL then SQLGL should XDOAPPL, if AP then SQLAP should assign XDOAPPL variable. but it is giving me the error.

APPL=$1
x=AP
y=GL
echo "Value of x = $x and y = $y."
a=SQLAP
b=SQLGL

if [["$APPL" = "AP"]};
then
XDOAPPL=${a}
echo "AP XDOAPPL =$XDOAPPL"
elif [["$APPL" = "GL"]];
then
XDOAPPL=${b}
echo "GL XDOAPPL =$XDOAPPL"
else
echo "Nothing to go"
fi
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

1 Answers1

1

When using [[ ]], you must leave a space between [[ or ]] and the content. You also mistyped a } instead of a ] in the first if.

Here is the correct code :

APPL=$1
x=AP
y=GL
echo "Value of x = $x and y = $y."
a=SQLAP
b=SQLGL

if [[ "$APPL" = "AP" ]];
then
  XDOAPPL=${a}
  echo "AP XDOAPPL = $XDOAPPL"
elif [[ "$APPL" = "GL" ]];
then
  XDOAPPL=${b}
  echo "GL XDOAPPL = $XDOAPPL"
else
  echo "Nothing to go"
fi
Hexdump
  • 126