2

When I execute script from terminal by hand, it runs without problems:

gksudo /path/to/module.sh

But when I use .desktop file to run script on startup:

[Desktop Entry]
Type=Application
Exec=gksudo /path/to/module.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=module
Comment=module

It runs at first but then crashes. Module basically is a infinite while loop, listening to process and if process is not running script runs command.

What can be a problem?

I'm using Lubuntu openbox

Script sample:

#!/bin/bash
export LD_LIBRARY_PATH=/home/user/modules/lib
EXECMOD="/path/to/module" # module is a C++ program
PNAME="module"

while [ : ]
do
    $EXECMOD

    ANS=$?
    if [ $ANS -eq 0 ]
        then
        break
    fi

    # Wait
    sleep 1
done
  • Hi notgiorgi, posted my answer. Please let me know if it works. – Jacob Vlijm Jan 26 '16 at 12:16
  • Can you show us a minimal example of your script that reproduces the problem? What do you mean by "It runs at first but then crashes."? Does it run correctly but it stops after a while? Does it run the first time you try but not the second? Does the gksu dialog appear? Please edit your question and clarify. – terdon Jan 26 '16 at 12:28
  • Thanks. Could you please answer my other questions as well? Edit your question and add the answers there. Also, the script you show will attempt to run module and stop the first time it launches it successfully. What is it that crashes? What are you expecting to happen and what actually happens? – terdon Jan 26 '16 at 13:34
  • This bash script should relaunch C++ program (module) if it stops running. Yes, it runs correctly and after a while crashes. gksudo dialog doesn't appear. – notgiorgi Jan 27 '16 at 7:08
  • Removed my answer and my request(s) below it, since it is unclear if it works or not. No offence, but you could be a bit more communicative. It helps finding out if an answer works or not. Useful to others as well. – Jacob Vlijm Jan 27 '16 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.