I'm looking for some help with launching a program in a new terminal window. I created a Go CLI program called 'CLauncher', and I want it to run when I press Win+R. I set up a shortcut to run a script called runner.sh, which should open a terminal and execute 'CLauncher' with the 'runw' argument (like 'CLauncher runw'). I tried using 'konsole -e CLauncher runw', and it works, but when I call it from a shell script, nothing happens. If I open the terminal first and then run the script, it works just fine. I also found that using '/bin/bash -c "CLauncher runw"' starts the program, but it ends up hidden. I'm wondering what I'm missing, especially since CLauncher waits for user input and doesn't terminate right away.
5 Answers
Your script should focus on directly calling your Go app, including all necessary arguments. If you're on Windows, remember that you don't need to explicitly call bash—just ensure your script is executed properly with the right shebang for bash.
I think the terminal is actually opening but it might be closing right away because it's finishing the command. You can use the '--hold' option with Konsole, like:
konsole --hold -e '/bin/bash -c "your_command_here"'
This way, the terminal will stay open after executing your command, allowing you to see any output or errors.
You can simply call the terminal application from the command line. It should be straightforward to execute 'konsole' along with your command in the script. Make sure your runner.sh file has the right shebang line to specify the shell, or else it may not work as intended. Like you said, the windows version usually depends on the file extension, but in bash, it's determined by the shebang.
Totally agree! Just ensure that your script has the right permissions to execute (use chmod +x runner.sh to give it execution permissions).
Just a thought: make sure the command you're trying to run doesn't have issues related to how the terminal handles background processes or input/output redirection. Tinkering with those settings might give you better results.
If you're using a GUI like X and want to open a terminal window to run your program, you should definitely confirm that the terminal emulator's syntax is correct. For instance, with xterm, you could launch it using something like:
xterm -e 'your_command_here'
Also, when you're trying to call it from a script, ensure that the DISPLAY variable is set correctly. That might be why you don’t see anything happening when running from the script—your environment variables might not be set as expected.
Good point! Another thing to try is adding 'export DISPLAY=:0' at the start of your script. That should help with the environment issue.

Yes! That's a great suggestion. Using 'exec bash' at the end of the command can also help keep the terminal open.