0
data=$(wget -qO - https://blockchain.info/fr/q/addressbalance/$pk)
if [$data != 0]; then
    echo "Hello"
else
    echo "good bye"
fi

I have tried a lot of possibilities. I don't know how to work this.

I don't understand why this condition doesn't work.

wget -qO - https://blockchain.info/fr/q/addressbalance/$pk if [$? != 0]; then echo "Hello" else echo "good bye" fi

Result: 192005332305./btc.sh: ligne 6: [0 : commande introuvable good bye

hn0x
  • 3
  • 3

1 Answers1

1

Command does not return the errorcode, use $?

wget -qO - https://blockchain.info/fr/q/addressbalance/$pk
if [ $? != 0 ]; then
    echo "Hello"
else
    echo "good bye"
fi

You should have space inside the bracket.

Here my code for test, works perfekt:

wget -qO - $1 > test.txt
if [ $? != 0 ]; then
    echo "Hello"
else
    echo "good bye"
fi
daddykom
  • 222
  • 2
  • 8