walletsBalance.sh: Clean output format in array, tmp output

This commit is contained in:
poka 2020-10-16 23:11:25 +02:00
parent 4da8bae7fa
commit bb00097c93
1 changed files with 13 additions and 7 deletions

View File

@ -16,15 +16,20 @@ work() {
balance=$(silkaj -p $node balance $i 2>/dev/null)
}
exec
while [[ $? == 1 ]]; do echo "Erreur $i $k" | tee -a silkaj_error.log; ((k++)); exec; done
while [[ $? == 1 ]]; do echo "Erreur $k: $i" | tee -a silkaj_error.log; ((k++)); exec; done
unset k
balance=$(awk '/Total Quantitative =/ { print $4 }' <<<"$balance")
[[ $1 == "members" ]] && username=$(curl -m 20 -s $DUNITER/wot/members | jq -r --arg pubkey "$i" '.results[] | select(.pubkey==$pubkey) | .uid')
formatedBalance="$balance"$'\t'"$i"
[[ $username ]] && formatedBalance="$formatedBalance"$'\t'"$username"
unset username
echo "$formatedBalance"
if [[ $1 == "members" ]]; then
username=$(curl -m 20 -s $DUNITER/wot/members | jq -r --arg pubkey "$i" '.results[] | select(.pubkey==$pubkey) | .uid')
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
unset username
else
formatedBalance=$(printf "%-10s | %-45s" $balance $i)
fi
unset balance
echo "$formatedBalance" | tee -a /tmp/balance-g1.txt
totalBalance="$totalBalance"$'\n'"$formatedBalance"
@ -42,4 +47,5 @@ wallets=$(cat $WEBPATH/data/wallets-g1-simple.txt 2>/dev/null)
work && unset wallets
totalBalance=$(sort -nr <<<$totalBalance)
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt