I have the following script:
#!/bin/bash
xterm -e ' sh -c "$HOME/TEST/FirstAPP --test;" exec bash'
## script opens the xterm and stops until I press CTRL+C
while true; do
....
this question is related to this question
Why does the script stop at this place? I need to get the xterm called and running and then continue with the code having FirstApp running.
I used the gnome-terminal without problems.
Best Answer
If you want your script to run a command and then continue executing, you need to tun the command in the background (
&
, see https://unix.stackexchange.com/a/159514/22222). So, change your script to:That will launch the
xterm
command in the background, keeping the terminal open andFirstAPP
running, and will then continue onto the other lines of your script.The reason it worked with
gnome-terminal
is because when you rungnome-terminal
, it apparently forks itself and returns control to the shell you launched it from. You can see this withstrace
:Note the calls to
clone
which, as explained inman clone
does:So, unlike most programs,
gnome-terminal
will make a clone of itself when launched. The normal way of launching something and then continuing with something else is to use&
to launch it in the background.