2

Here is my desktop entry to run "PRGM.sh"

[Desktop Entry]
Encoding=UTF-8
Name=PRGM
Comment=Launch PRGM
Exec=gksu /home/markku/PRGM.sh
Icon=utilities-terminal
Type=Application
Terminal=true

The program runs in terminal and at the end outputs a code I want to check. But the desktop entry runs the program in terminal and closes when it finishes so can't check the code. How can I modify the desktop entry to not close the terminal after execution? (It is required to use gksu)

2
  • Other possible solution: have the script send its output to a text file then open it with your text editor. If that would work, I can give you more details. – wjandrea Jul 26 '16 at 18:34
  • The "edit gnome-terminal settings" option is only one I got working from these, but I would prefer not to use that as it affect everything. I rather read the code straight from terminal. Tried "gksu "bash /home/markku/PRGM.sh;bash"" and "gksu /home/markku/PRGM.sh;bash" and other variations but no results. It doesn't work the same as I need to use this "gksu" to get sudo. Feel free to suggest inputs to this, as I'm not very familiar with this stuff. – Make465213 Jul 26 '16 at 19:32
3

Use @Dane's solution (copied here):

read -n1 -p "Press any key to exit."
exit

And change two lines in the .desktop file:

Exec=gksu "gnome-terminal -x bash -c /home/markku/PRGM.sh"
...
Terminal=false

Or if sudo would work fine, it's simpler:

Exec=sudo /home/markku/PRGM.sh
...
Terminal=true
0
2

At the end of the script, remove any "exit", and replace it with:

read -n1 -p "Press any key to exit."
exit

This will display the quoted message, and wait for the user to press a key, after which it will exit. You can put a number (or variable containing a number) after "exit" to exit with a status, if desired.

1
  • Thanks for your reply. Unfortunately that didn't work. It works fine if I run this desktop entry in terminal, but not when I just open it. The scipt ends in if...else...fi statement. After the "fi" there are the lines which print the code I'm looking for. – Make465213 Jul 26 '16 at 18:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.