I'm trying to increment indx and eindx values inside a ssh session.but none of commands are working..
#!/bin/bash
hosts=( #10.xx.xx.xx )
PdidPrefix1=$1
Runtime=$2
indx=$3
eindx=`expr $indx + $4`
logfilename=$5
for i in "${hosts[@]}"
do
echo $i
ssh centos@$i << EOF
for var in {1..4}
do
indx=`expr $eindx + 1` // not working
eindx=$((indx+eindx)) // not working
done
EOF
done
exit
tried using let also
let "indx=indx+1" //not working
Kindly suggest best way to handle variables.
'EOF') to prevent variable expansion on the local host?$i. While not the cause, using$((...))arithmetic is correct, leaveexpr a + bin the past. Have you tried with$((...))arithmetic in all instances where you are doing math?EOF,it is throwing an error that it cannot resolve $var which i'm trying to use in another command