Very simple question about shell script

I think I’m kinda stupid, but I just spent two hours googling for the answer to this question: how to write a script which will:

  1. execute itself in konsole from krusader with double-click or enter
  2. pause for any key pressing and close this konsole afterwards
    Something like this:
echo "test"
read -p "Press any key to exit ..."
  1. I made the file with ‘executable’ permission, but the only way to run this file is right click → ‘Run In Konsole’, double-click or enter has no effect
  2. exit command in script has no effect either, I suggest I can’t even stop the script with CTRL+C

Really embarrassed for this question, sorry for poor English and of course - thank you in advance!

You’re going about it the wrong way in your interpretation of what happens. If you left-click the name of a shell script from within a graphical environment, then it does get executed — or at least, if the file has the execute permission set for your user account — but your entire graphical environment is itself an application running inside a virtual console.

UNIX systems are multi-user and therefore support multiple terminals. The script has no idea what terminal it must send its output to.

If you want the script to interact with konsole — which is a pseudoterminal — then you must invoke it by way of a .desktop file. You already have a multitude of such files installed for other applications — e.g. under /usr/share/applications or ~/.local/share/applications — but the ones that open up a pseudoterminal window should be of interest to you, so I would recommend looking at the .desktop file for htop.


This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.