32 lines
922 B
Bash
Executable File
32 lines
922 B
Bash
Executable File
#!/bin/bash
|
|
|
|
DUNITER=$(grep g1_node ../config/config.php | awk '{ print $3}' | tr -d ';' | tr -d "'")
|
|
TXBLOCKS=$(curl -s $DUNITER/blockchain/with/tx | jq '.result.blocks[]')
|
|
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 5 | tr '\n' ' ')
|
|
keyword="\[Achat GMarche] : "
|
|
|
|
for i in $TXBLOCKS; do
|
|
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"')
|
|
|
|
#result=$(echo "$result" | grep "$keyword")
|
|
[[ ! -z $result ]] && isSell+=$(echo -e "$result;") && echo "$result"
|
|
echo ---
|
|
sleep 1
|
|
done
|
|
|
|
# isSell="[Achat GMarche] : testCesium" # Test hors sol
|
|
isSell=$(echo $isSell | sed "s/$keyword//g")
|
|
|
|
echo "$isSell est vendu"
|
|
|
|
IFS=';'; ADDR=($isSell); unset IFS;
|
|
for i in "${ADDR[@]}"; do
|
|
req="UPDATE products SET status = 'solde' WHERE name = '$i';"
|
|
echo "$req"
|
|
# sudo mysql --database gmarche -e "$req"
|
|
done
|
|
|
|
sudo mysql --database gmarche -e "SELECT name,status FROM products;"
|
|
|
|
exit 0
|