FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 07-03-2008, 02:16 PM
"James B. Byrne"
 
Default Running shell scripts from external media

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@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




_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-03-2008, 02:53 PM
Greg Bailey
 
Default Running shell scripts from external media

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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-03-2008, 03:19 PM
Stephen Harris
 
Default Running shell scripts from external media

> 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
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-03-2008, 03:29 PM
Nicolas Thierry-Mieg
 
Default Running shell scripts from external media

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

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 01:13 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org