I want to ask the question "What format do you want to use?", then, depending on whether the answer is xml or json, print the appropriate output. However, if it is not xml or json, then the code finishes.
Code:
#!/bin/bash
read -r -e -p "What format do you want to use? json/xml?: " format
if [[ "${format,,}" == "json" ]]; then
curl=$curl"\"\Content-Type: application/json\"\
else [[ "${format,,}" == "xml" ]]; then
curl=$curl"\"\Content-Type: application/xml\"\
elif [[ "${format,,}" == "no" ]]; then
echo "Goodbye, you must specify a format to use Rest"
else
echo "Unknown"
exit 0
fi
echo $curl
I receive this error when I try to run it:
[root@osprey groups]# ./test3
What format do you want to use? json/xml?: xml
./test3: line 8: syntax error near unexpected token `then'
./test3: line 8: `elif [[ "${format,,}" == "no" ]]; then'