Tuesday, October 18, 2016

bash - Syntax Error: Unexpected end of file


I'm trying to run this script below and I have no idea why its not working. I keep getting an error message that says "Syntax Error: Unexpected end of file" and I don't know how to trouble shoot this


#!/bin/bash
Add_Entry(){
echo "Go Flight"
pause
}
Delete_Entry(){
echo "Go Flight"
pause
}
View_Entry() {
echo "Go Flight"
pause
Show_menus() {
echo "~~~~~~~~~~~~~~~~~~~~~"
echo " M A I N - M E N U"
echo "~~~~~~~~~~~~~~~~~~~~~"
echo "1. Add Entry"
echo "2. Delete Entry"
echo "3. View Entry"
echo "4. Exit"
}
Exit(){
exit
}
Read_options(){
echo "Please choose from the menu"
read choice
case $choice in
1) Add_Entry ;;
2) Delete_Entry ;;
3) View_Entry ;;
4) Exit ;;
esac
}
# Main
while true
do
Show_menus
Read_options
done

The Add Entry, View Entry and Delete Entry are just full of dummy code at the moment. Still I have no idea why I'm getting this error. Any help would be most appreciated!



The View_Entry() block isn't closed. i.e. it should be


View_Entry() {
echo "Go Flight"
pause
}

Fixing this makes the script work for me. If you use a text editor with syntax hightlighting (e.g. vim or kate, perhaps gedit?) this is easy to spot.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...