Startserver.sh: line 58: unexpected EOF while looking for matching./startserver.sh: line 61: syntax error: unexpected end of file?

Re
- in Servers
21

I have the problem I can't find the mistake someone could help me am just a beginner.

Want to do a Minecraft server starter.

#! / bin / bash

if [-f craftbukkit-1.16.5.jar]; then
echo "Skipping download. Using existing craftbukkit-1.16.5.jar"
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar
if [[$ DO_RAMDISK -eq 1]]; then
sudo umount $ SAVE_DIR
rm -rf $ SAVE_DIR
mv "$ {SAVE_DIR} _backup" $ SAVE_DIR
fi
else
export URL = "https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar"
fi
echo $ url
which wget >> / dev / null
if [$? -eq 0]; then
echo "DEBUG: (wget) Downloading $ {URL}"
wget -O craftbukkit-1.16.5.jar "$ {URL}"
else
which curl >> / dev / null
if [$? -eq 0]; then
echo "DEBUG: (curl) Downloading $ {URL}"
curl -o craftbukkit-1.16.5.jar "$ {URL}"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
fi
fi

if egrep -q eula = true eula.txt; then
echo Starting…
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
exit
else
Height = 15
WIDTH = 40
CHOICE_HEIGHT = 4
BACKTITLE = "Bukkit"
TITLE = "Choice"
MENU = "Do you accet the eula at (https://account.mojang.com/documents/minecraft_eula)?"
OPTIONS = (1 "Yes
2 "No")

CHOICE = $ (dialog --clear \
--backtitle "$ BACKTITLE" \
--title "$ TITLE" \ --menu "$ MENU" \
$ HEIGHT $ WIDTH $ CHOICE_HEIGHT \
"$ {OPTIONS [@]}" \
2> & 1> / dev / tty)

clear
case $ CHOICE in
1)
echo "You accepted the eula…"
sed s / false / true / g eula.txt
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
;;
2)
echo "You not Accepted the eula"
;;
fi

Ge

Just as you must terminate every if statement with fi, you must also terminate every case statement with esac.

The latter is missing from your script.

Then take a look at the lines

OPTIONS = (1 "Yes
2 "No")

at. If I see that correctly, a final quota is still missing after the yes.

Re

Well, as I said above, I'm not a professional and I don't know what quotes are either

Re

And should I add 'esac' before or after 'fi'?

Ge

Well, the quotation marks.

"Yes"

instead of

Ge

Before the last fi, because the case statement still logically belongs in the if statement.

Re

#! / bin / bash

if [-f craftbukkit-1.16.5.jar]; then
echo "Skipping download. Using existing craftbukkit-1.16.5.jar"
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar
if [[$ DO_RAMDISK -eq 1]]; then
sudo umount $ SAVE_DIR
rm -rf $ SAVE_DIR
mv "$ {SAVE_DIR} _backup" $ SAVE_DIR
fi
else
export URL = "https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar"
fi
echo $ url
which wget >> / dev / null
if [$? -eq 0]; then
echo "DEBUG: (wget) Downloading $ {URL}"
wget -O craftbukkit-1.16.5.jar "$ {URL}"
else
which curl >> / dev / null
if [$? -eq 0]; then
echo "DEBUG: (curl) Downloading $ {URL}"
curl -o craftbukkit-1.16.5.jar "$ {URL}"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
fi
fi

if egrep -q eula = true eula.txt; then
echo Starting…
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
exit
else
Height = 15
WIDTH = 40
CHOICE_HEIGHT = 4
BACKTITLE = "Bukkit"
TITLE = "Choice"
MENU = "Do you accet the eula at (https://account.mojang.com/documents/minecraft_eula)?"
OPTIONS = (1 "Yes"
2 "No")

CHOICE = $ (dialog --clear \
--backtitle "$ BACKTITLE" \
--title "$ TITLE" \ --menu "$ MENU" \
$ HEIGHT $ WIDTH $ CHOICE_HEIGHT \
"$ {OPTIONS [@]}" \
2> & 1> / dev / tty)

clear
case $ CHOICE in
1)
echo "You accepted the eula…"
sed s / false / true / g eula.txt
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
;;
2)
echo "You not Accepted the eula"
;;
esac
fi

Also when I add 'esac' it comes "./startserver.sh: line 58: unexpected EOF while looking for matching '"'

./startserver.sh: line 62: syntax error: unexpected end of file ".

Ge

Another suggestion for improvement: instead

which wget >> / dev / null
if [$? -eq 0]; then

do you write

if which wget> / dev / null; then

and instead of

else
which curl >> / dev / null
if [$? -eq 0]; then

do you write

elif which curl> / dev / null; then

Re

Thanks anyway esac I have the above error

Ge

The first error message: then something is probably right with the line

java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui

not yet. However, I don't know the order very well either. At the moment it is also a little unclear to me what exactly you are assigning to the variable CHOICE. You're doing something with a dialogue; but are you sure that in the end it really only comes out 1 or 2?

You could try this out by putting a # in front of each line of the case… Esac part and then using the variable above this part

echo $ CHOICE

can be spent.

Re

If I understand correctly I should do it like this:

case $ CHOICE in
#1)
echo "You accepted the eula…"
sed s / false / true / g eula.txt
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
;;
# 2)
echo "You not Accepted the eula"
;;
esac

Ge

No, the whole part, so like this:

# case $ CHOICE in
# 1)
# echo "You accepted the eula…"
# sed s / false / true / g eula.txt
# java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
# ;;
# 2)
# echo "You not Accepted the eula"
# ;;
# esac
echo $ CHOICE

Ge

Or better still at the end:

echo "The value of the variable is:" $ CHOICE

Then you also know where the value in the output comes from.

Re

No, the syntax error still occurs

./startserver.sh: line 54: unexpected EOF while looking for matching '"'
./startserver.sh: line 59: syntax error: unexpected end of file

Ge

That's right, with the elif there's still one fi too much in it. Please put in there again #

if which wget> / dev / null
echo "DEBUG: (wget) Downloading $ {URL}"
wget -O craftbukkit-1.16.5.jar "$ {URL}"
elif which curl> / dev / null
echo "DEBUG: (curl) Downloading $ {URL}"
curl -o craftbukkit-1.16.5.jar "$ {URL}"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
# fi
fi

Re

It still comes with an unexpected end of file

./startserver.sh: line 55: unexpected EOF while looking for matching '"'
./startserver.sh: line 60: syntax error: unexpected end of file

Ge

You changed something afterwards in the last comment. Before that there was something with "line 24".

This makes it difficult to help you.

Re

Here again the whole script and debug

#! / bin / bash

if [-f craftbukkit-1.16.5.jar]; then
echo "Skipping download. Using existing craftbukkit-1.16.5.jar"
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar
if [[$ DO_RAMDISK -eq 1]]; then
sudo umount $ SAVE_DIR
rm -rf $ SAVE_DIR
mv "$ {SAVE_DIR} _backup" $ SAVE_DIR
fi
else
export URL = "https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar"
fi
echo $ url
if which wget> / dev / null; then
echo "DEBUG: (wget) Downloading $ {URL}"
wget -O craftbukkit-1.16.5.jar "$ {URL}"
elif which curl> / dev / null; then
echo "DEBUG: (curl) Downloading $ {URL}"
curl -o craftbukkit-1.16.5.jar "$ {URL}"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
# fi
fi

if egrep -q eula = true eula.txt; then
echo Starting…
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
exit
else
Height = 15
WIDTH = 40
CHOICE_HEIGHT = 4
BACKTITLE = "Bukkit"
TITLE = "Choice"
MENU = "Do you accet the eula at (https://account.mojang.com/documents/minecraft_eula)?"
OPTIONS = (1 "Yes
2 "No")

CHOICE = $ (dialog --clear \
--backtitle "$ BACKTITLE" \
--title "$ TITLE" \
--menu "$ MENU" \
$ HEIGHT $ WIDTH $ CHOICE_HEIGHT \
"$ {OPTIONS [@]}" \
2> & 1> / dev / tty)

clear
# case $ CHOICE in
# 1)
# echo "You accepted the eula…"
# sed s / false / true / g eula.txt
# java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
# ;;
# 2)
# echo "You not Accepted the eula"
# ;;
# esac
echo $ CHOICE
fi

-------------------------------------------------- --------------------------

Skipping download. Using existing craftbukkit-1.16.5.jar
*** Error, this build is outdated ***
*** Please download a new build as per instructions from https://www.spigotmc.org/...ted-spigot ***
*** Server will start in 20 seconds ***
Loading libraries, please wait…
[23:15:45] [main / INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

DEBUG: (wget) Downloading
http://: Invalid host name.
./startserver.sh: line 55: unexpected EOF while looking for matching '"'
./startserver.sh: line 60: syntax error: unexpected end of file

Re

I solved Line 24 myself and forgot to write it down

Ge

Hmm, the error messages don't make sense to me at the moment. The # at the beginning means that the line marked accordingly should be ignored during execution.

Line 55 reads:

# sed s / false / true / g eula.txt

Line 60 reads:

# ;;

Is there anything else in your script in between?

Re

No, I did copy and paste

here again:

#! / bin / bash

if [-f craftbukkit-1.16.5.jar]; then
echo "Skipping download. Using existing craftbukkit-1.16.5.jar"
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar
if [[$ DO_RAMDISK -eq 1]]; then
sudo umount $ SAVE_DIR
rm -rf $ SAVE_DIR
mv "$ {SAVE_DIR} _backup" $ SAVE_DIR
fi
else
export URL = "https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar"
fi
echo $ url
if which wget> / dev / null; then
echo "DEBUG: (wget) Downloading $ {URL}"
wget -O craftbukkit-1.16.5.jar "$ {URL}"
elif which curl> / dev / null; then
echo "DEBUG: (curl) Downloading $ {URL}"
curl -o craftbukkit-1.16.5.jar "$ {URL}"
else
echo "Neither wget or curl were found on your system. Please install one and try again"
# fi
fi

if egrep -q eula = true eula.txt; then
echo Starting…
java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
exit
else
Height = 15
WIDTH = 40
CHOICE_HEIGHT = 4
BACKTITLE = "Bukkit"
TITLE = "Choice"
MENU = "Do you accet the eula at (https://account.mojang.com/documents/minecraft_eula)?"
OPTIONS = (1 "Yes
2 "No")

CHOICE = $ (dialog --clear \
--backtitle "$ BACKTITLE" \
--title "$ TITLE" \
--menu "$ MENU" \
$ HEIGHT $ WIDTH $ CHOICE_HEIGHT \
"$ {OPTIONS [@]}" \
2> & 1> / dev / tty)

clear
# case $ CHOICE in
# 1)
# echo "You accepted the eula…"
# sed s / false / true / g eula.txt
# java -Xmx5G -Xms5G -jar craftbukkit-1.16.5.jar nogui
# ;;
# 2)
# echo "You not Accepted the eula"
# ;;
# esac
echo $ CHOICE
fi

-------------------------------------------------- --------------------------

https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar
DEBUG: (wget) Downloading https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar
--2021-03-13 23:34:28 - https://cdn.getbukkit.org/craftbukkit/craftbukkit-1.16.5.jar
Resolving cdn.getbukkit.org (cdn.getbukkit.org)… 149.28.57.95
Connecting to cdn.getbukkit.org (cdn.getbukkit.org) | 149.28.57.95 |: 443… Connected.
HTTP request sent, awaiting response… 200 OK
Length: 35571609 (34M) [application / java-archive]
Saving to: 'craftbukkit-1.16.5.jar'

craftbukkit-1.16.5.jar 100% [========================================= =========>] 33.92M 5.68MB / s in 6.4s

2021-03-13 23:34:35 (5.27 MB / s) - 'craftbukkit-1.16.5.jar' saved [35571609/35571609]

./startserver.sh: line 56: unexpected EOF while looking for matching '"'
./startserver.sh: line 61: syntax error: unexpected end of file

Ge

Then I'm not getting any further at the moment. Perhaps there will be someone with more experience who can explain this. The script shouldn't stumble over these two lines.

Above all, the fact that the line numbers change after another run is a mystery to me. Normally they should always be the same.

Script Error Message? Sh Shockbakery71
Minecraft server error? - 1 Bo Bodhimelodic