Find the answer to your Linux question:
Results 1 to 5 of 5
Hi friends, I have saved my shell script with .sh extension in desktop. If i have to run the script,the normal course of action is --opening the terminal --sh file.sh ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jul 2007
    Posts
    144

    executing script


    Hi friends,
    I have saved my shell script with .sh extension in desktop.
    If i have to run the script,the normal course of action is
    --opening the terminal
    --sh file.sh

    but iwant to execute the script on double clicking the script itself.

    RH Linux 7.3.

    Thanks

  2. #2
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    The first line should look like this:
    #!/bin/sh
    And then chmod +x
    Then it is executable. Note, if it uses bash specific commands and not 100% bourne compliant sh commands, you should specify /bin/bash instead of /bin/sh so you won't have problems in the future if /bin/sh is ever pointing to a real bourne shell instead of bash.

  3. #3
    Linux Newbie
    Join Date
    Jul 2007
    Posts
    144
    i don't want to type:
    $sh file.sh

    in order to execute a script.

    i want to run the script whenever i click on the file in graphical mode.

  4. #4
    Linux Engineer
    Join Date
    Nov 2004
    Location
    home
    Posts
    796
    That's what I just explained how to do. You might need to remove the .sh extension, as the gui might see that and open it up in an editor, but other than that you would need to do what I already said. The chmod +x will make it executable, and the #!/bin/sh tells the shell which interpreter to use to run the script.

  5. #5
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,393
    Remove the sh extension as mentioned above, and then create a shortcut to your program either in the menu or an icon. You may have to choose the option to run the program in a terminal so that you can see the output.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •