diff --git a/scripts/walletsBalance.sh b/scripts/walletsBalance.sh index be5ba94..c227bb2 100755 --- a/scripts/walletsBalance.sh +++ b/scripts/walletsBalance.sh @@ -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