FAQ
OSÎntOS-5.2
media=Kingston 512Mb usb key

Problem:
As 'root', when running a script resident on the external drive mounted at
/media/disk I receive the following error:

/bin/sh: bad interpreter: Permission denied

The meduia is a 512Mb USB key formatted as ext2/3

# ll
-rwx------ 1 root root 28 Jul 2 17:30 hello.sh

# cat hello.sh
#!/bin/sh
echo Hello World!

# which sh
/bin/sh

I believe that this can be resolved by an entry in /etc/fstab but I cannot
determine what entry to make.

# cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,modeb0 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/VolGroup00/LogVol03 /home ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol02 /tmp ext3 defaults 1 2
/dev/VolGroup00/LogVol04 /var/log ext3 defaults 1 2
/dev/VolGroup00/LogVol05 /var/www ext3 defaults 1 2
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
From the logs I gather that the device is sda1
Jul 2 16:42:45 inet02 kernel: SCSI device sda: 1001472 512-byte hdwr
sectors (513 MB)
Jul 2 16:42:45 inet02 kernel: sda: Write Protect is off
Jul 2 16:42:45 inet02 kernel: sda: assuming drive cache: write through
Jul 2 16:42:45 inet02 kernel: sda: sda1
Jul 2 16:42:45 inet02 kernel: sd 0:0:0:0: Attached scsi removable disk sda
Jul 2 16:42:45 inet02 kernel: EXT2-fs warning: mounting unchecked fs,
running e2fsck is recommended
Jul 2 16:42:46 inet02 hald: mounted /dev/sda1 on behalf of uid 500

I deduce from the various bits of information that I have gleaned thatthe
proper entry in fstab should be something like:

/dev/sda1 /disk auto defaults,user,exec 0 0

However, this is an automounted, removable media. How do I do enable
execute for this key and retain the auto mount capability? What impact
will this have on other usb keys?

--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3

Search Discussions

  • Greg Bailey at Jul 3, 2008 at 2:53 pm

    James B. Byrne wrote:
    Problem:
    As 'root', when running a script resident on the external drive mounted at
    /media/disk I receive the following error:

    /bin/sh: bad interpreter: Permission denied
    Usually, I've found this is because the file is stored with DOS style
    line endings.
    Maybe you could try:

    dos2unix -n hello.sh hello2.sh
    chmod +x hello2.sh
    ./hello2.sh

    Does that fix it?

    Greg
  • Stephen Harris at Jul 3, 2008 at 3:19 pm

    As 'root', when running a script resident on the external drive mounted at
    /media/disk I receive the following error:

    /bin/sh: bad interpreter: Permission denied
    Are you sure the script isn't in DOS format, with CRLF line endings? If
    so then the interpreter it's trying to run is actually /bin/sh^M (with
    a control-M at the end). Which is wrong :-)

    Try running dos2unix on it and trying it again.

    --

    rgds
    Stephen
  • Nicolas Thierry-Mieg at Jul 3, 2008 at 3:29 pm

    James B. Byrne wrote:
    OS=CentOS-5.2
    media=Kingston 512Mb usb key

    Problem:
    As 'root', when running a script resident on the external drive mounted at
    /media/disk I receive the following error:

    /bin/sh: bad interpreter: Permission denied <snip>
    I deduce from the various bits of information that I have gleaned thatthe
    proper entry in fstab should be something like:

    /dev/sda1 /disk auto defaults,user,exec 0 0

    However, this is an automounted, removable media. How do I do enable
    execute for this key and retain the auto mount capability? What impact
    will this have on other usb keys?
    I think you have the right diagnostic, the key is mounted with the
    noexec flag.
    You can confirm this by typing "mount" when the usb key is mounted.

    But I don't know the answers to your questions...

    However if it fits your usefase you could invoke the shell yourself:
    /bin/sh hello.sh

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcentos @
categoriescentos
postedJul 3, '08 at 2:16p
activeJul 3, '08 at 3:29p
posts4
users4
websitecentos.org
irc#centos

People

Translate

site design / logo © 2021 Grokbase