1

Im trying to make work the next bash code, but seems that Im doing things wrong:

hostname=`hostname -s`
qaiservers={'v-qai01' 'v-qai02'}


for i in ${qaiservers[@]}
do
        if [[ $i = ${hostname} ]]; then
                echo 1
        else
                echo 0
        fi
done

The current hostname is v-qai01 which is supposed to match with the verification, but it doesnt:

./run.sh: line 14: v-qai02}: command not found
./run.sh: line 15: }: command not found

Thank you

FIXED:

Made it work with:

hostname=`hostname -s`

qaiservers=("v-qai01" "v-qai02")
#portales={'t1wsyellar01' }

for i in "${qaiservers[@]}"
do
    if [ "$i" == "${hostname}" ] ; then
        echo "Found"
    fi
done

Made it work thanks to this link

Community
  • 1
  • 1
BoDiE2003
  • 1,287
  • 6
  • 28
  • 41

1 Answers1

2
qaiservers=('v-qai01' 'v-qai02')