Announcement

Collapse
No announcement yet.

Execute .sh file by double clicking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [RESOLVED] Execute .sh file by double clicking

    Hey people! Ok i have a quick question. I've written a simple yes no bash script. I know i can run it from the terminal but i was wondering if there's anyway of executing it by means of double clicking it with the mouse. Please keep in mind I'm brand new to bash.

    #2
    I should emphasize the script is in kdialog but if needs be i can rewrite it in dialog.

    Comment


      #3
      How are you running the script in the terminal? If you are using the source or . commands the execute permission is not checked.

      To check if the script is executable in dolphin, right click the file, properties, permissions tab, check "Is executable", or in a konsole, it should look something like
      Code:
      $ ls -l *.sh
      -rwxrwxr-x 1 john john 99 Aug 29 13:59 t.sh
      The x means executable. (In a konsole, you could use chmod +x to set the executable bits.)

      If it is marked executable, there can be other reasons dolphin doesn't want to run it. In dolphin's settings, configure dolphin, General, confirmations tab, there is the "When opening an executable file" drop down; I have it set to "always ask".

      If the script is on removable media, the media is normally mounted with the "noexec" option, but the source command will still work IIRC.
      Regards, John Little

      Comment


        #4
        Hiya Jittle!! Thanks for getting back to me. When i execute the files i do it through the terminal by entering ./ before the .sh file.

        the ls command gave me the following:
        -rwxrwxr-x 1 yikes yikes 319 Oct 30 17:37 chatgpt2revised.sh
        -rwxrwxr-x 1 yikes yikes 317 Oct 30 17:17 chatgpt.sh
        -rwxrwxr-x 1 yikes yikes 116 Nov 1 17:29 exist.sh
        -rwxrwxr-x 1 yikes yikes 32 Oct 30 16:55 fselect1.sh
        -rwxrwxr-x 1 yikes yikes 181 Nov 1 17:36 gemini.sh
        -rwxrwxr-x 1 yikes yikes 339 Nov 1 17:42 getopenfilename.sh
        -rwxrwxr-x 1 yikes yikes 103 Nov 1 17:33 kdgetfileopen.sh
        -rwxrwxr-x 1 yikes yikes 339 Oct 30 17:57 kdialog.sh
        -rwxrwxr-x 1 yikes yikes 735 Nov 1 16:50 kyesno.sh
        -rwxrwxr-x 1 yikes yikes 137 Nov 1 17:09 mygo.sh
        -rwxrwxr-x 1 yikes yikes 147 Oct 31 17:34 newyesno.sh
        -rwxrwxr-x 1 yikes yikes 366 Oct 31 17:22 texttomsg.sh
        -rwxrwxr-x 1 yikes yikes 502 Oct 30 19:00 vpn1.sh
        -rwxrwxr-x 1 yikes yikes 735 Nov 1 17:50 vpnconnect.sh
        -rwxrwxr-x 1 yikes yikes 735 Nov 1 17:56 vpnyesnodisconnect.sh
        -rwxrwxr-x 1 yikes yikes 195 Oct 31 17:31 yesno.sh


        Here's the annoying part, two of the .sh files run when i double click them.

        Is there anything more i can add to help me sort this out?

        Comment


          #5
          Ok the weirdest thing just happened. I looked at the two files that do actually run. Both of them had
          #!/bin/bash

          When i looked at one of the scripts that wouldn't run there was a double line. I changed it and reran the files, guess what! It works.

          In hindsight probably posted the code here, I don't doubt you guys would have picked up on the error.

          Thanks for your help Jittle!!

          Comment

          Working...
          X