Can't execute created scripts.

Discussion in 'Unix' started by TheKidd88, Jul 6, 2007.

  1. TheKidd88

    TheKidd88 New Member

    Joined:
    Jun 28, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    I created a new script (runThis) and included line: "$chmod +x runThis" then I save and quit, and type ./runThis into the shell, but it says that permission is denied.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am not a *nix guy but you can see if you have the execute permission for the file you are trying to run.
     
    Last edited: Jul 7, 2007
  3. munkyeetr

    munkyeetr New Member

    Joined:
    May 4, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Victoria BC, Canada
    A couple of things to look for:

    Are you the owner of the file you are trying to chmod, or running as root/sudo?
    If the user that is trying to change the permission doesn't have enough permissions to change the permissions (deep breathe) you will get a permission denied message.

    So, you will have to run the script as either root or sudo, or add sudo to the script like this:

    Code:
        sudo chmod +x runThis
        
    Now the user running the script will be prompted for their password (they will have to be listed in the /etc/sudoers file) and if they enter it the script will run the command. If not, or if they are not in the sudoers file, they will receive a permission denied message.
     
  4. TheKidd88

    TheKidd88 New Member

    Joined:
    Jun 28, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    I created the file, so I don't know why I wouldn't have permission. I also tried the sudo thing and it still says permission denied.
     
  5. munkyeetr

    munkyeetr New Member

    Joined:
    May 4, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Victoria BC, Canada
    Right-click on the file and choose Properties or in a Terminal window open to the directory where the file is and type:
    Code:
        ls -la
        
    Does it list you as the Owner of the file? I have no problem running that command on a file that I've created.

    Also, as I said before, sudo will not work if you're not listed in the the /etc/sudoers file.

    What Linux distribution are you running?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice