There is a need to run the program (Feed The Beast Launcher) with a preliminary choice, so to speak, of the launch mode. I am writing a sh-скрипт this kind:

 #!/bin/bash IFS=$'\n' FTBDir="Путь" MMWPDir="Путь" JarLaunchDir="$HOME/Programs" NameLaunch="FTB_Launcher.jar" echo "Режим запуска:" echo "1.Обычный" echo "2.Сброс клиента" cd $JarLaunchDir read test java -jar ./$NameLaunch& 

I would like the terminal to close after launching the program. But the log of the operation of the launcher itself starts to appear in the terminal, respectively, everything after the launch line is not executed, therefore it is not possible to close the terminal.

I suppose that you need to somehow run in a separate thread, but I don’t understand how to do it.

  • one
    stackoverflow.com/questions/10247721/… ; Either use screen ; Or supervisor ; Or write an init script. - nobody
  • one
    программа параметры & exit - aleksandr barakin
  • Can it be easier and more convenient to make a shortcut with several launch options, as it is done for example in /usr/share/applications/firefox.desktop ? - sercxjo
  • @sercxjo, Maybe it's easier, but I do not want to produce labels in the side panel. In fact, I will run every time in different modes, In order to do this hemorrhagic. - BwehaaFox
  • @alexanderbarakin, everything turned out to be not so simple, but simply - BwehaaFox

1 answer 1

Thanks to the link provided by nobody and the method of typing, the solution is as follows:

You need to change java -jar ./$NameLaunch to the following:

 nohup java -jar ./$NameLaunch & sleep 0.01 exit 

That is, 2 subtleties:

  1. Must be a sleep with a value greater than 0
  2. exit must be separate and not via &
  • Somehow unscientific. Why sleep ? - Roman
  • @Roman, Why, I did not understand the truth. But in the same topic it was sort of described why. I didn’t go into details, I just checked in practice that yes, without sleep, it doesn’t support - BwehaaFox
  • @BwehaaFox not, stackoverflow should be scientific - andreymal
  • Did you try disown instead of sleep ? Yes, with I / O redirection to /dev/null ? - Roman