1

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".

h0ch5tr4355
  • 664
  • 9
  • 20
  • 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 09 '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 09 '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 09 '15 at 11:50
  • I have some user entries in the script and Terminal=false isn't possible so. – h0ch5tr4355 Sep 09 '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 09 '15 at 11:57
  • Added the script. Is there a way to format it easier by copy+paste? Too bad the echoes are in my mother tongue, but i guess its not important – h0ch5tr4355 Sep 09 '15 at 12:09
  • added the script, but also found a solution for the problem in this post: http://askubuntu.com/a/437030/448613 – h0ch5tr4355 Sep 09 '15 at 12:28
  • Ah, yes. Cool! I'll vote to close this as a dupe then. – terdon Sep 09 '15 at 12:40

0 Answers0