Facing issue while passing "ip_addr" in url using shell script [duplicate]
Solution 1:
if (${env} == "qa"); then
ip_addr = "x.x.x.47"
else
ip_addr = "x.x.x.53"
fi
Firstly, what is intended to be the if condition, is actually the request to run ${env} == "qa"
in a subshell. This does not make sense. You need to use double bracket notation, or the test
builtin. The former looks like:
if [[ ${env} == "qa" ]]
Secondly, no spaces are allowed between variable, equal sign, and value in assignments. It must read:
ip_addr="x.x.x.47"
The complete if looks like this:
if [[ ${env} == "qa" ]]; then
ip_addr="x.x.x.47"
else
ip_addr="x.x.x.53"
fi