Results 1 to 8 of 8

Thread: Shell Scripts Won't Execute

  1. #1
    Join Date
    May 2009
    Location
    Michigan
    Beans
    176
    Distro
    Lubuntu 14.04 Trusty Tahr

    Shell Scripts Won't Execute

    I'm sure this is a simple fix, but I can't figure it out. I have a shell script called wom.sh in the directory ~/wom_linux. When I double-click the file in PCManFM, I am asked if I want to open, execute, or run in terminal. Opening the file opens it in Leafpad for editing. Executing and executing in terminal both do nothing. Also,

    Code:
    $:~/wom_linux$ wom.sh
    wom.sh: command not found
    It will run if I use "./wom.sh", though. How do I execute from the GUI?
    T

  2. #2
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,505
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by temporos View Post
    I'm sure this is a simple fix, but I can't figure it out. I have a shell script called wom.sh in the directory ~/wom_linux. When I double-click the file in PCManFM, I am asked if I want to open, execute, or run in terminal. Opening the file opens it in Leafpad for editing. Executing and executing in terminal both do nothing. Also,

    Code:
    $:~/wom_linux$ wom.sh
    wom.sh: command not found
    It will run if I use "./wom.sh", though. How do I execute from the GUI?
    Like with all Unix/Linux files, set the Execute bit.

    Everything is working exactly as it should.

    Code:
    man chmod
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  3. #3
    Join Date
    Sep 2012
    Beans
    4

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by temporos View Post
    I'm sure this is a simple fix, but I can't figure it out. I have a shell script called wom.sh in the directory ~/wom_linux. When I double-click the file in PCManFM, I am asked if I want to open, execute, or run in terminal. Opening the file opens it in Leafpad for editing. Executing and executing in terminal both do nothing. Also,

    Code:
    $:~/wom_linux$ wom.sh
    wom.sh: command not found
    It will run if I use "./wom.sh", though. How do I execute from the GUI?
    You must read about linux directory structure and what is a binary on a *nix system.

    1) Set the eXecution bit to the permissions of your script:

    chmod +x wfm.sh

    2) Create a symbolic link to your script into , i.e., /usr/local/bin:

    ln -s /home/whatever/folder/wom_linux/wom.sh /usr/local/bin/wom.sh

    3) Profit.

  4. #4
    Join Date
    Jan 2005
    Location
    South Africa
    Beans
    2,098
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by dcstar View Post
    Like with all Unix/Linux files, set the Execute bit.
    How does that help if ./wom.sh works ?
    If you don't make backups of your important data, your data is obviously not important to you.

  5. #5
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    2,533
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by pr0misc View Post
    2) Create a symbolic link to your script into , i.e., /usr/local/bin:

    ln -s /home/whatever/folder/wom_linux/wom.sh /usr/local/bin/wom.sh
    WHY?

    Personal scripts or binaries should go into ~/bin/, which once it is created and you have have logged in again, is automatically in your $PATH.

    Note that in Linux, your current directory is NOT in your $PATH by default for your own safety, to avoid accidentally executing something you do not intend to.
    i5 650 3.2 GHz, 8 GB, nvidia GTX 550 Ti 32" 1080p | i7-4700, 8 GB, Intel HD 4600/nvidia GTX 765M 15.6" 1080p | etc.

  6. #6
    Join Date
    May 2009
    Location
    Michigan
    Beans
    176
    Distro
    Lubuntu 14.04 Trusty Tahr

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by pr0misc View Post
    Create a symbolic link to your script into , i.e., /usr/local/bin:
    ln -s /home/whatever/folder/wom_linux/wom.sh /usr/local/bin/wom.sh
    Did that already. No joy. Still works only when I execute it using "./wom.sh" while in the directory.


    Quote Originally Posted by dcstar View Post
    Like with all Unix/Linux files, set the Execute bit.
    The x-bit is already set. If it wasn't, then "./wom.sh" wouldn't work, either.
    T

  7. #7
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Shell Scripts Won't Execute

    Since I usually execute scripts in a terminal window, I'm not sure I'm an expert on this. Also, I don't know how different Kubuntu is from your DE. I think, though, that just double clicking .sh scripts to run is not enabled by default. I think you either can:

    1. Right click on it, choose to open with another application, and choose to run it from the terminal. On Kubuntu, you can create an association with that file type there too, which I presume will allow one to double click and launch .sh scripts from then on (not tested this, though).

    2. Create a launcher or shortcut for the script. I found this on the LDXE wiki page:

    http://wiki.lxde.org/en/LXShortCut

    Hope that helps!

  8. #8
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,084
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Shell Scripts Won't Execute

    Quote Originally Posted by temporos View Post
    Executing and executing in terminal both do nothing.
    Of course the script is executable because ./wom.sh works. Simply typing the name in a terminal will not work - this is completely normal behaviour because ~/wom_linux is not in your path. If you want to be able to run it from the command line without specifying a path, then do
    Code:
    PATH=~/wom_linux:$PATH
    and add it to ~/.bashrc . However, that will not solve your original problem.

    How do you know that selecting the options "execute" amd "execute in terminal" do nothing? What is the script supposed to do? Perhaps add
    Code:
    date >> ~/wom_linux/wom.log
    at the top of the script to test whether it is actually running. If the script is running but not doing what you expect, then you'd probably need to post the script for further help.

Tags for this Thread

Bookmarks

Posting Permissions

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