Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Unable to run shell script

  1. #1
    Join Date
    Oct 2010
    Beans
    18

    Angry Unable to run shell script

    i have a shell script at the following location

    /media/1E30D23B30D2199B/matu20Xa/update/install/main.sh

    when i try to run it as ./main.sh

    it returns the reply

    Code:
     bash: ./main.sh: Permission denied
    i am logged in a root

    still i am facing this problem

    i have tried doing chmod +x and also chmod u+x but in vain

    anyone help please

  2. #2
    Join Date
    Oct 2010
    Beans
    18

    Re: Unable to run shell script

    someone help please

  3. #3
    Join Date
    Dec 2008
    Location
    Northwest Ohio
    Beans
    1,581
    Distro
    Lubuntu 13.10 Saucy Salamander

    Re: Unable to run shell script

    Hi,

    i am logged in a root
    Do you mean you are logged into a terminal as root?

    Is the file owned by "you" or "root" if you right click on it and check the permissions? Have you tried running the script with "sudo" yet?
    Code:
    sudo /media/1E30D23B30D2199B/matu20Xa/update/install/main.sh
    I think 'chown' might be better than using 'chmod u' for setting user permissions:
    [sudo chown userid:groupid /path/to/file]
    Code:
    sudo chown shanks:shanks /media/1E30D23B30D2199B/matu20Xa/update/install/main.sh
    OR
    sudo chown 1000:1000 /media/1E30D23B30D2199B/matu20Xa/update/install/main.sh
    (assuming you are user 1000)
    Now try executing the script again.

    PS. Here are more details about chmod and chown for Ubuntu.
    https://help.ubuntu.com/community/FilePermissions

    PSS You might have to run the script with "sh" if "bash" doesn't understand it. I ran into that problem a couple of times.
    Code:
    sh /media/1E30D23B30D2199B/matu20Xa/update/install/main.sh
    Hope this helps.
    Last edited by ankspo71; January 12th, 2011 at 11:27 AM.

  4. #4
    Join Date
    Jul 2009
    Location
    London
    Beans
    1,480
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Unable to run shell script

    my guess is that this is a vfat or ntfs filesystem and since 10.04 these are mounted with a 'showexec' option which means that text files are not executable.

    just run it using bash or sh instead.

    Code:
    bash /path/to/your/file
    or
    Code:
    sh /path/to/your/file

  5. #5
    Join Date
    Dec 2008
    Location
    Northwest Ohio
    Beans
    1,581
    Distro
    Lubuntu 13.10 Saucy Salamander

    Re: Unable to run shell script

    Quote Originally Posted by DaithiF View Post
    my guess is that this is a vfat or ntfs filesystem and since 10.04 these are mounted with a 'showexec' option which means that text files are not executable.

    just run it using bash or sh instead.
    Yep, thanks for mentioning that. I just tried a script of my own on my second drive (formatted in xfs) and it didn't work either:
    Code:
    sudo /media/sdb7/kubuntu-packages
    [sudo] password for james: 
    sudo: unable to execute /media/sdb7/kubuntu-packages: Permission denied
    'sudo bash' and 'sudo sh' worked like a charm. (my particular script calls for sudo to install packages)
    Last edited by ankspo71; January 12th, 2011 at 11:40 AM.

  6. #6
    Join Date
    Oct 2010
    Beans
    18

    Re: Unable to run shell script

    when i said i was logged in as root, what i meant was that i was logged in as user `root`

    and not form the terminal

    and guys i have tried all the options of bash, sh u have given above

    still i get same reply


    bash: ./main.sh: Permission denied

  7. #7
    Join Date
    Oct 2010
    Beans
    18

    Re: Unable to run shell script

    even when i right click on properties and then try to change the permissions, event hat does not seem to be possible

    as i am not able to change the permissions there at all

  8. #8
    Join Date
    Oct 2010
    Beans
    18

    Re: Unable to run shell script

    no one?

  9. #9
    Join Date
    Aug 2009
    Beans
    824

    Re: Unable to run shell script

    If you type
    Code:
    bash myfile
    It doesn't matter what the rights on the file are, as long as you can read it you can execute it.

    The reason why you can't execute it like
    Code:
    ./myfile
    might be given in a previous post:
    my guess is that this is a vfat or ntfs filesystem and since 10.04 these are mounted with a 'showexec' option which means that text files are not executable.

  10. #10
    Join Date
    Aug 2005
    Beans
    10

    Re: Unable to run shell script

    Here is a somewhat hackish way to patch away the "showexec" option from the automounter:

    Code:
    sudo sed -i -e 's|showexec|\x00\x00\x00\x00\x00\x00\x00\x00|g' /usr/lib/udisks/udisks-daemon
    CAUTION: Works for me after a reboot, but no guarantees. Make a backup before you do this!

Page 1 of 2 12 LastLast

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
  •