Why is this loop not breaking(ending due to if
statement) or using the newly incremented value of $c
variable? Tried c=expr $c + 1 with and without "
double quote.
export c=1; ssh auser@someserver "until [[ 1 -eq 2 ]]; do echo \"Value of 'c' == $c\"; c=`expr $c + 1`; echo \"$c - Incremented value: `expr $c + 1`\"; if [[ $c -gt 5 ]]; then break; fi; sleep 2 ; done;"
or
$ export c=1; ssh root@$CHEF_SERVER \
> "until [[ 1 -eq 2 ]]; do \
> echo \"Value of 'c' == $c\"; c=`expr $c + 1`; \
> echo \"$c - Incremented value: `expr $c + 1`\"; \
> if [[ $c -gt 5 ]]; then break; fi; \
> sleep 2; \
> echo; \
> done;"
Output is infinte: I had to ^c it.
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Value of 'c' == 1
1 - Incremented value: 2
Killed by signal 2.