I have a bash script [.sh file] Thescript; the script is to generate a random number and user have tothe user guess it.
printf 'Guess the number (1-10) : '
read -r n
randint=$(( ( RANDOM % 10 ) + 1 ))
if [ $n = $randint ];
then
echo "You Won !"
else
echo "Sorry, try again !"
fi
It works, but in the next script I have encoded this code into bas64base64 and tried to run it using the following code.
exec="cHJpbnRmICdHdWVzcyB0aGUgbnVtYmVyICgxLTEwKSA6ICcKcmVhZCAtciBuCnJhbmRpbnQ9JCgoICggUkFORE9NICUgMTAgKSAgKyAxICkpCgppZiBbICRuID0gJHJhbmRpbnQgXTsKdGhlbgplY2hvICJZb3UgV29uICEiCmVsc2UKZWNobyAiU29ycnksIHRyeSBhZ2FpbiAhIgpmaQ=="
base64 -d <<< $exec | sh
It gives anthis error [Cygwin Terminal] in a Cygwin Terminal:
Guess the number (1-10) : sh: line 4: [: too many arguments
Sorry, try again !
I tried an online compiler and it failed also:
sh: 5: [: =: unexpected operator
I dontdon't know what to do i am tired of searching google. Hope somebody seefix this .