shellshminecraftopenbsdbungeecord

How to run multiple .sh files from different directories


SO I have a BSD server and want to host a Minecraft BungeeCoord server. The thing is the server files are in different directories EG: /home/name/bungee/servers/Survival/start.sh AND /home/name/bungee/servers/Lobby/start.sh

Is there a way to make a file that can run multiple files from different directories ?

Just to make it clear, the reason I want to do this is because the BSD server can only take 1 file at a time, like shell/terminal.

Edit: The command I ended up using was screen


Solution

  • somewhat sorted by least to most advanced

    example 1

    sh /home/name/bungee/servers/Survival/start.sh &
    sh /home/name/bungee/servers/Lobby/start.sh &
    

    & runs the process as a background job freeing the terminal (STDIN) though not STDOUT and STDERR streams meaning the output still goes to the terminal

    use jobs(1) command of ksh(1) (OpenBSD default shell) to view those jobs controllable by your shell afterwards

    example 2

    after cd path gets shorter

      cd /home/name/bungee/servers
      sh ./Survival/start.sh &
      sh ./Lobby/start.sh &
    

    you may also redirect both output to file instead of to the screen using the redirection capability of your shell such as with > output.log 2>&1

    example 3

    use multiple (virtual) terminals? (ctrl+alt+f1 and ctrl+alt+f2) logging in into each separately, and then launch a script per tty(4)

    example 4

    use a programming language library such as IPC::Cmd to fork processes with run_forked function