Linux: How to auto open terminal when a script is run

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error Linux: How to auto open terminal when a script is run on this date .

Ok, so I am going to write a script and I need it to auto open xterm when I double-click it (similar to a BAT on Windows). It needs to work on ANY desktop that includes xterm. So for example it would do a check if it was already running in xterm then if not it would reopen itself in xterm and if it is the script will continue its process. Sorry if this has already been asked but I was unable to find anything for the life of me.

Answer

You can do this as follows:

xterm -e program [ arguments ... ]

From the linux man page…

This option specifies the program (and its command line arguments) to be run in the xterm window. It also sets the window title and icon name to be the basename of the program being executed if neither -T nor -n are given on the command line. This must be the last option on the command line.