Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've created a desktop entry in ~/.local/share/applications. It looks similiar to the following:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Crontona Server
GenericName=CA Server
Comment=BDAF server for Crontona
Exec=bash "/usr/local/crontona/run.sh"
Icon=/usr/local/crontona/app.ico
Terminal=true
Type=Application

It show's up in the Unity launcher and everything, but whenever I click it, the terminal just pops up but instantly closes. I have no problems at all with using 'bash ./.....run.sh' but I've had no success through the menu. Any idea why it happens?

This is the content of the run.sh file:

#!/bin/bash
./corona_run -prot tcp +maxcon 16
share|improve this question
2  
What happens if you just use Exec=/usr/local/crontona/run.sh ? –  glenn jackman May 8 '12 at 18:59
    
Hmm... "There was an error creating the child process for this terminal. Failed to execute child process /usr/local/crontona/run.sh (Permission denied)". Seems like a permission problem... Then, how do I execute 'with' permission through a desktop shortcut? –  Elliott Darfink May 8 '12 at 19:03
2  
Perhaps "run.sh" is not executable? What does ls -la /usr/local/crontona/run.sh say? –  SirCharlo May 8 '12 at 19:20
    
Perhaps you need Exec=sudo /usr/local/crontona/run.sh -- I'm not familiar with these, so I don't know if you need quotes. –  glenn jackman May 8 '12 at 19:23
1  
Ok.. Does the "run.sh" file have the appropriate shebang and path to the bash interpreter on the first line? For example: #!/bin/bash –  SirCharlo May 8 '12 at 20:25
show 9 more comments

1 Answer 1

Add the command read x as the last line in run.sh. This read will cause the command window to remain open until you press return. If any messages are displayed this gives time to read them.


The read is the key. Here is a shell script (I prefer it to bash although bash is becoming as popular). BTW, the .sh at the end means shell script, not script. You could change your launcher Exec option to:

Exec="/usr/local/crontona/run.sh"

And use the following run.sh script...

#!/bin/sh
./corona_run -prot tcp +maxcon 16
echo -n Press enter to end...
read x
echo Ending Now\!

Notice I escaped the ! in the Ending Now. That last line is not needed unless you are running the script inside a terminal and want to have it echo execution. This way, if the terminal appears and the script is run inside the terminal, the script will not exit until you press enter so the terminal cannot close until you are ready.

share|improve this answer
    
Or, in the .desktop-file, Exec=bash -c '/path/to/script; read -p "Hit enter to close"' –  geirha Jul 27 '12 at 15:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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