I am a beginner to bash scripting. I need help to figure out what is wrong with this tput menu.
#!/bin/bash
tput setb 3
tput clear
function main_menu
{
option=0
until [ "$option" = "4" ]; do
echo " 1.) Monitor existing processes "
echo " 2.) Copy passwd to /home directory "
echo " 3.) Ping local host "
echo " 4.) Exit "
echo -n "Enter choice:"
read option
echo ""
case $option in
1 ) ps aux;echo "The list has been successfully generated!";
2 ) cp /etc/passwd /home;echo "The passwd file has been copied to your home directory.";
3 ) ping -c 4 127.0.0.1;echo "You have completed pinging localhost" );
4 ) exit;;
* ) tput setf 4;echo "Please enter between number 1 and 4";tput setf 4;
esac
done
}
I've made it in the If/Then statement, and that works but I am trying to learn on using tput.
if/then ( is working) #!/bin/bash clear echo "Main Menu " echo "1. Monitor existing processes " echo "2. Copy passwd to /home directory " echo "3. Ping local host " echo "4. Exit "
read num
if [ $num -eq 1 ]
then ps aux
echo "The list has been successfully generated! "
elif [ "$num" -eq 2 ]
then cp /etc/passwd /home
echo "The passwd file has been copied to your home directory."
elif [ "$num" -eq 3 ]
then ping -c 4 127.0.0.1
echo "You have completed pinging localhost"
elif [ "$num" -eq 4 ]
then clear
fi
Thanks!