[CentOS] Running shell scripts from external media

James B. Byrne byrnejb at harte-lyne.ca
Thu Jul 3 14:16:46 UTC 2008


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

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,mode=620  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 at 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







More information about the CentOS mailing list