![]() |
-ne argument expected WHY doesnt this work
I,m having a problem with this script, it is supposed to be a random number guessing game but it wont work. Can anyone tell me why????
here is the code Code:
biggest=200 |
Imigine that the #!/bin/sh is there like it is in my script
|
I got it working this way, I just renamed the variable $number to $variable because $number did not exist in your code.
#!/bin/sh biggest=200 smallest=1 large=201 little=-1 guess=0 guesses=0 variable=$(( $$ % biggest )) while [ $guess -ne $variable ] do echo -n "please guess a number" read guess if [ "$guess" -lt $variable ] then echo "The number is higher than that" elif [ "$guess" -gt $variable ] then echo "pick a smaller number" elif [ "$guess" -gt $large ] then echo "number is way to big, always pick lower than 200 or will be here all night!!" elif [ "$guess" -lt $little ] then echo "Its not a negative number, guess a positive number please" fi guesses=$(( $guesses + 1 )) done echo "Finally your got it. your guessed $variable finally in $guesses guesses!" -jax |
Duh, but that code doesnt work for me either for some reason?????
I get this error message [: +] bad number then it echos my final statement?? |
what line
|
it doesnt say
it just says ./(scriptname) [: +: bad number Finally you got it. you guessed +964 % biggest (some cross looking character I cant type) finally on 0 guesses! thats all it says? Is it in my last echo ??? |
the only + sign I see in the script is the guesses=$(( $guesses + 1 ))
|
not sure because it works for me, what dirtro are u using
|
dirtro , ? I ,m a total newb, I,m using cywin for windows though if thats what your asking.
|
All times are GMT -5. The time now is 01:14 PM. |