I am having issues with this script and don't know exactly what is happening.
#Main Menu
clear
while [ "$input" -eq "0" ];
do
clear
#$input == 0
echo "Hello, What would you like me to do?"
echo ""
echo "1 = ALL TEH THINGZ!"
echo "2 = Find the enemy postions and villages"
echo "3 = Set the firewalls to my liking"
echo "4 = Confuse the enemy"
echo "5 = Deploy the spies!"
echo "6 = DISABLED Run the TOP SECRET STUFF! (Note password is required)"
echo "81 = Burn the bridges! (Cautian: Last Resort)"
echo "96 = Install/Update Software (locally)"
echo "97 = Install/Update Software (remotely)"
echo "98 = Update and add new Kali tools"
echo "99 = I am done with you for now"
read -p "Select an operation for me to do: " $input
I know I have the fi and end right but I am getting an error at the while [ "$input" -eq "0" ];
You'll get that message if $input is not a legal numeric expression; for instance, if it's the empty string. If you want to loop while it's 0, you should start out by setting it to 0.
input=0
while [ "$input" -eq 0 ]; do
...
done
Although you've tagged this bash; if you're actually using bash, you can also do this:
while (( input == 0 )); do
...
done
Note that shell is not Perl; the $ is not part of the variable name. It's better to think of $ as an operator that means "get the value of". The variable is input; you assign it with input=; you read into it with read input; etc. You only use $input when you want to get the value stored in the variable.
So, for instance, it doesn't make sense to do $input= or read $input unless the value stored in the input variable is a string which is the name of some other variable that you want to set the value of.
The problem is at
while [ "$input" -eq "0" ]
and you have not used the while loop closing statement done, too.
As you are comparing two strings, you should use
while [[ $input == 0 ]]; do <statements>; done
or
while [ $input = 0 ]; do <statements>; done
So your code will be:
#Main Menu
clear
echo -n "Select an operation for me to do: "
read input
while [ $input = 0 ]
do
clear
done
#$input == 0
echo "Hello, What would you like me to do?"
echo ""
echo "1 = ALL THE THINGZ!"
echo "2 = Find the enemy postions and villages"
echo "3 = Set the firewalls to my liking"
echo "4 = Confuse the enemy"
echo "5 = Deploy the spies!"
echo "6 = DISABLED Run the TOP SECRET STUFF! (Note password is required)"
echo "81 = Burn the bridges! (Cautian: Last Resort)"
echo "96 = Install/Update Software (locally)"
echo "97 = Install/Update Software (remotely)"
echo "98 = Update and add new Kali tools"
echo "99 = I am done with you for now"
exit 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With