I have a test shell script that works when I right-click on the file in Dolphin and select “Run in Konsole.”
I have attempted to add an entry to the KDE application launcher, but the script fails to complete after a brief flash of what I suspect is the console. I have tried modifying the settings in the KDE Menu Editor and the .desktop file directly, but without success.
I may be missing something, but when you execute a script (or any program) “in a console”, I assume that a terminal emulator (probably konsole in KDE) is started where this program is then a child process. When there is any ouput to stdout or stderr, you will see that text in the console and when it reads from stdin, I guess it waits until you type ending with a return. And when the program exits, I would expect the console also exiting.
Thus when you only have some output (of the ls command) that will be put to the console and then the console will disapear. All in a wink (ecept when the ls listing is very long and you will see it flashing by).
As you told things happened to your satisfaction when using Dolpin > Right-click on file > Actions > Execute in Konsole, I tried that also. To my surprise the Konsole window shows the output and then stays on the screen??? I could not exit in the normal way (Ctrl-C and/or Ctrl-D), thus I had to kill the window (not the neatest way of working).
Next step was checking what is running. From the ps -ef listing:
Btw, it depends on what you are doing, but a simple
read
as last statement of the script wil let the whole thing wait on a hit on the Return key. Will also work on other terminal emultaors, I do not know if xterm has a --hold lookalike.
Thank you. I just tried the “read” command at the end of the script, removing the --noclose terminal option, and I like that better for this purpose. It provides confirmation of the execution and then closure by hitting return.