Issue
I want to launch several applications using "./application_name" and each in separate terminal , how do i do that in bash script.
Solution
I am not sure I understand what you are asking for, but this is probably what you need:
x-terminal-emulator -e "./application_name [arguments]" &
This will start a new terminal emulator in the background which will be running the given command instead of a shell.
If you system does not have a x-terminal-emulator
alias, substitute the name of an actual terminal emulator, like xterm
or gnome-terminal
. They (pretty much) all support the -e
option.
Of course this requires that your bash script be running from inside an X11 session in the first place (not from a cron job or something like that), else there will be no $DISPLAY
where the new terminal emulators can appear.
EDIT: Whether or not the argument to -e
is executed under a shell or directly seems to depend on which terminal emulator is used. For example, xterm
runs it under a shell but gnome-terminal
doesn't. The upshot of this is that you may or may not be able to supply compound shell commands like cd foobar; ./something & wait
as the argument to -e
. As a workaround for those terminal emulators that don't run the command under a shell, you can use -e 'sh -c "actual command"'
. Proper quoting of special characters gets gets complicated because you have two levels of quoting, but it can be done.
Answered By - Celada Answer Checked By - Katrina (WPSolving Volunteer)