Write a .sh script for Linux

Hi everyone

I am hosting a 4 Minecraft Server for some friends from a PC that is running Mint. I am trying to write a script, making it possible to start them all with one click. It used to work, but after moving the Server-folders around it stopped working an I was not able to fix it. (tho I changed the directory and changed privileges. I don’t know why it woun’t work as I did not change anything at the base code of my .sh files.

So this is how my system is set up->

I use the startServer.sh script to fire up the start1.sh,start2.sh,start3.sh and start4.sh skripts located in my MC_Server folder.

The start1.sh,… files then start the different servers.

As it is, the different terminals (I need 1 terminal per server) start but are not able to load the designated script and there is a error.

startServer.sh (Schreibtisch)

gnome-terminal -e Dokumente/MC_Server/start1.sh
gnome-terminal -e Dokumente/MC_Server/start2.sh
gnome-terminal -e Dokumente/MC_Server/start3.sh
gnome-terminal -e Dokumente/MC_Server/start4.sh


start1.sh (Dokumente/MC_Server/start1.sh)

cd Dokumente/MC_Server/MinecraftServer
echo “Server1”
java -Xmx2G -Xms1G -jar craftbukkit.jar ngui


Sorry I am swiss so everything is in german. But the Error says it can’t find the directory or the file.

Error:
Kindprozess »Dokumente/MC_Server/start4.sh« konnte nicht ausgeführt werden (Datei oder Verzeichnis nicht gefunden)

If I manually tip the code into the terminal it works, like it should, but if I run the script it does not.

What am I doing wrong?

I am logged in as a power user but not root, if this is a issue.

Thanks in advance Janick

what’s the working directory you’re executing the script from? You’re using relative paths, maybe change them to absolute paths.

something like: gnome-terminal -e /home/Janick/Dokumente/MC_Server/start1.sh

change the path to the actual path :wink:

7 Likes

Hey thank you so much, I was trying this all day and now it works. :confetti_ball::confetti_ball::confetti_ball:

1 Like