Ok i have this code below when i enter option 3, once it goes through and that part is done, i cant get it to display the menu options again. It only works with "break ;;" but the break just exits the script
while true do
clear
echo
"Menu Options: "
echo "1. Create Script"
echo "2. Show Script"
echo "3. Exit"
echo " Choose: " read options
case "${options}" in
1)
read -p "Enter script name" $name
echo "$name" >> web.txt
;;
2)
echo "Your script"
cat web.txt
;;
3)
read -p "Publish your public_html directory? (y|n)" publish
if [ "$publish" = "y" ];
then
read -p "Enter name of webpage to publish:" publishedpage1
cp WEB.txt ~/public_html/$publishedpage1
echo "Enter to continue"
else
echo "Webpage has not been published"
fi
;;
4)
echo "Exitting."
exit 0
;;
esac done
If the code is really as you've posted it, it must be throwing syntax errors all over the place, not just not working right. You've got line breaks -- and lack of line breaks -- in very strange places. You have to have them in the right places in a shell script.
while true
do
clear
echo "Menu Options: "
echo "1. Create Script"
echo "2. Show Script"
echo "3. Exit"
echo " Choose: "
read options
case "${options}" in
1)
read -p "Enter script name" $name
echo "$name" >> web.txt
;;
2)
echo "Your script"
cat web.txt
;;
3)
read -p "Publish your public_html directory? (y|n)" publish
if [ "$publish" = "y" ];
then
read -p "Enter name of webpage to publish:" publishedpage1
cp WEB.txt ~/public_html/$publishedpage1
echo "Enter to continue"
else
echo "Webpage has not been published"
fi
;;
4)
echo "Exitting."
exit 0
;;
esac
done
sorry about that, i was trying to fix up the spacing and everything. But the script works, but i cant solve my problem of displaying the menu options again after executing option 3