Announcement

Collapse
No announcement yet.

[SOLVED] Problem running script from GUI

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Problem running script from GUI

    This is starting to drive me insane!

    I have a script. It works fine from the command prompt. (I've got the SUDOERs file right) It is in my home directory, it works on its own but I can't run it via the GUI.

    If I click on it to run it, it doesn't run.

    If I create a link to it, nothing happens when I try and use the link.

    If I tell the link to run in a terminal, it returns...
    "Warning: Could not start program '/home/michelle/CD-mount.sh' with arguments '/home/michelle/CD-mount.sh'."

    If I adjust the advanced properties of the link, to get it to run as another user, even if I give it my name, then it asks for my password and then runs the script.

    ... so I've got something wrong here somewhere. Any ideas please?

    #2
    Re: Problem running script from GUI

    Post the script if you don't mind, so we can look at it.
    Windows no longer obstructs my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      Re: Problem running script from GUI

      Are the permissions ok? Is it executable?

      Comment


        #4
        Re: Problem running script from GUI

        HI,

        Yes, the script is executable and runs perfectly fine from a fresh command prompt without asking for a password.

        The script is the one for the DVD mounting that I wrote before...
        sudo umount /media/cdrom0
        sudo mount -t iso9660 /dev/scd0 /media/cdrom0
        sudo umount /media/cdrom1
        sudo mount -t iso9660 /dev/scd1 /media/cdrom1
        ...and executes fine as the sudoers entries allow me to use mount and umount without a password prompt.

        The key issue is, if I tell the link to run the script as another person, it asks for the password and then runs it; but if I tell it not to run as another user, I get the error message mentioned earlier.

        Comment


          #5
          Re: Problem running script from GUI

          First of, do you have a specific reason why you need/want to mount your disks via a script (and using sudo)...you should be able to mount with device notifier widget. You can also allow users to mount disks (without using sudo).

          If I click on it to run it, it doesn't run.
          Are you sure it doesn't run...or does it just not do what it is supposed to do?
          To check whether your script runs at all, add a line at a start of your script:
          Code:
          echo $(date) >> ~/my_script_ran
          This will write the time into a file (which will be created if it doesn't exist) in your home directory (/home/michelle/my_script_ran). The file either confirms the script was executed (the file was created and there is something wrong with the script) or not (the file was not created and there is problem trying to execute the script from GUI).

          If I create a link to it, nothing happens when I try and use the link
          Can you post the contents of the link .desktop file (it's a text file you can open with kate or another text editor)


          I made a test script and it ran fine when clicked on, and also ran when clicking on a link to it (so your problems should be solvable).

          Comment


            #6
            Re: Problem running script from GUI

            Hi Kubicle,

            The reason for running the script is because some commercial DVDs aren't mounting properly automatically. Whey they mount, they have user and group ID's that are in the tens of thousands, and I can't access them properly. This isn't happening with older DVDs but some of the recent DVD's like Sanctuary and Family Guy series 7 and 8.

            In order to get at them, I have to unmount and remount them. Hence the script.

            When I run the script from the command line, the script takes a few moments to run. When I try with the terminal option enabled, I'm assuming that the result is the same ... ie. the error message.

            I'm at work at present, but when I get home in a few hours, I'll post the contents of the link. Good to hear there is a likely solution!

            Michelle.

            Comment


              #7
              Re: Problem running script from GUI

              Here it is...

              [Desktop Entry]
              Comment[en_GB]=DVD mount change
              Comment=DVD mount change
              Exec=~/CD-mount.sh
              GenericName[en_GB]=DVD mount change
              GenericName=DVD mount change
              Icon=exec
              MimeType=
              Name[en_GB]=DVD mount change
              Name=DVD mount change
              Path=
              StartupNotify=false
              Terminal=true
              TerminalOptions=
              Type=Application
              X-DBUS-ServiceName=
              X-DBUS-StartupType=none
              X-KDE-SubstituteUID=true
              X-KDE-Username=michelle
              X-Ubuntu-Gettext-Domain=desktop_kdebase


              ...like I said, if the username is blank it brings up the error message. If it has a user name in it, it asks for the password and then runs the script.

              Comment


                #8
                Re: Problem running script from GUI

                Did you try using a fully qualified path instead of
                Code:
                Exec=~/CD-mount.sh

                Comment


                  #9
                  Re: Problem running script from GUI

                  Yep, just tried it. Same error message in the terminal window (with no username given)

                  Comment


                    #10
                    Re: Problem running script from GUI

                    what happens if you add to

                    path=
                    path=/home/michelle/CD-mount.sh

                    and

                    Exec=~/CD-mount.sh
                    to
                    Exec=CD-mount.sh

                    ?

                    VINNY
                    i7 4core HT 8MB L3 2.9GHz
                    16GB RAM
                    Nvidia GTX 860M 4GB RAM 1152 cuda cores

                    Comment


                      #11
                      Re: Problem running script from GUI

                      The error changes to -

                      Warning: Could not find 'CD-mount.sh', starting '/bin/bash' instead. Please check your profile settings.

                      Comment


                        #12
                        Re: Problem running script from GUI

                        Does the first line of your script contain a comment containing the program name to execute the script?
                        Code:
                        #!/bin/sh

                        Comment


                          #13
                          Re: Problem running script from GUI

                          and is CD-mount.sh

                          in /home/michelle ?

                          VINNY

                          i7 4core HT 8MB L3 2.9GHz
                          16GB RAM
                          Nvidia GTX 860M 4GB RAM 1152 cuda cores

                          Comment


                            #14
                            Re: Problem running script from GUI

                            Skunk - bingo! You got it! Many thanks. I learned something new

                            Comment


                              #15
                              Re: [SOLVED] Problem running script from GUI

                              Isn't that the way it always is.... it's the little things that get us!
                              "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                              – John F. Kennedy, February 26, 1962.

                              Comment

                              Working...
                              X