Although this error is quite common and explained almost everywhere on the web I've decided to ask a new question since I can't get a clue for this specific case.
I'm trying to get some data out of Zimbra Collaboration Suite and the only way I can do it is via bash.
Being my first time with bash I find it a bit hard to deal with.This is the code:
#!/bin/bash
all_account=`zmprov -l gaa`;
declare -i szquota
szquota=524288000
for account in ${all_account}
do
mb_size=`zmmailbox -z -m ${account} gms`;
set -i size;
declare -i quota
declare -i quota2
for size in ${mb_size}
do
if [ $((10#$size)) -gt $((10#$szquota)) ] ; then
quota=`zmprov ga ${account} zimbraMailQuota`;
quota2="10#`zmprov ga ${account} zimbraMailQuota`";
echo "${account},${mb_size},$quota2\n";
fi
done
done
and this is the response:
line 12: 137,08: value too great for base (error token is "08")
I need to print all the accounts that have a quota of more than 500MB, and the output should be like this: account/quota/used quota.
Since mb_size
is an array of values I can't figure out how I could convert its content to a decimal base as I did with the other values?
It probably is much simpler than my mind makes it look but I really can't get out of this trouble.
Kind regards
EDIT:
Thanks @Alfe!
I've modified the code like this:
#!/bin/bash
all_account=`zmprov -l gaa`;
szquota=524288000
for account in ${all_account}
do
mb_size=`zmmailbox -z -m ${account} gms`;
declare -i quota
declare -i quota2
for sizeStr in ${mb_size}
do
if [ $size -gt $((10#$szquota)) ] ; then # <--- line 13
quota=`zmprov ga ${account} zimbraMailQuota`;
quota2="10#`zmprov ga ${account} zimbraMailQuota`";
echo "${account},${mb_size},$quota2\n";
fi
done
done
but it returns another error: line 13: [: -gt: unary operator expected
I've also tried to enclose the values inside the if clause between quotation marks but if I'm not wrong bash interprets the content of quotation marks as a string and gives back this:
line 13: [: : integer expression expected
I'm sure I'm getting closer to a solution but I'm still stuck at the moment.