1

This question already has an answer here:

I created the following Desktop Entry:

[Desktop Entry]
Type=Application
Terminal=true
Name=<name>
Exec=<pathTOscript/myScript.sh>

myscript.sh is just one command to start a service. The service starts the programm itself (CNTLM) and another script (own state).

sudo /etc/init.d/cntlm <ownstate>

Now my problem:

When I type the above command into a terminal: CNTLM stops, the script is executed, CNTLM starts, everything works fine.

However, when I click the shortcut, the terminal closes before CNTLM starts again.

Changing my .desktop to this solved the problem: Found it in this post.

[Desktop Entry]
Type=Application
Terminal=true
Name=<name>
Exec=gnome-terminal -e "bash -c 'sudo /etc/init.d/cntlm   <ownstate>;$SHELL'"

The important here was "$SHELL".

marked as duplicate by terdon, Jacob Vlijm, Thomas Ward, Eric Carvalho, muru Sep 18 '15 at 5:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Could you edit your question and show us the actual commands? Is the Exec command using sudo? How would you enter your password? – terdon Sep 9 '15 at 11:39
  • Which "actual commands" do you mean? Only sudo /etc/init.d/cntlm configure is in the script. A terminal pop-ups and asks me for the password. The other script is executed and isn't the problem. The - i call it "branch" - back to init.d/cntlm is missing somehow. Can you put sudo directly into the Exec? Maybe this would help... – h0ch5tr4355 Sep 9 '15 at 11:48
  • No, you can't, that's what I thought you were doing, so hat's why I asked for the command :). I'm not sure I understand the issue. Your .desktop file will launch the script itself in a terminal and then close the terminal. The child processes are not relevant. Have you tried running it with Terminal=false? – terdon Sep 9 '15 at 11:50
  • I have some user entries in the script and Terminal=false isn't possible so. – h0ch5tr4355 Sep 9 '15 at 11:56
  • The details of what's going on will depend on the script. I think what's happening is that the script is launched. However, since your script launches other things, and presumably in the background, the terminal running the parent process exits before the children have finished. I can't help unless you show us either the actual scripts or a minimal example that reproduces the problem though. – terdon Sep 9 '15 at 11:57