Pages

Tuesday, September 6, 2011

bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied

Hello All,
               Recently I have faced an interesting issue during command execution. I have given executable permission, But still getting permission denied error like "bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied"

I have done some searching and finally found exact issue. Actually I was working on my externally USB hard Disk. So by default it mounts with executable permission. Let me show you below:

Before doing any changes(default mount)
[root@server199 scripts]# ./iptest.sh
bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied

Now I have check default permission on mounted Disk

[root@server199 ~]# mount | grep disk
/dev/sdb1 on /media/disk type vfat (rw,noexec,nosuid,nodev,shortname=winnt,uid=0)

So its mounted with noexec Permission.

Now remount Disk with Executable permissions as shown below and then check:

[root@server199 ~]# cd

[root@server199 ~]# mount -t vfat /dev/sdb1 /media/disk/ -oremount,rw,exec,nosuid,nodev

[root@server199 ~]# mount | grep disk
/dev/sdb1 on /media/disk type vfat (rw,nosuid,nodev)

[root@server199 ~]# cd /media/disk/scripts/

[root@server199 scripts]# ./iptest.sh
enter ip adress
192.168.2.102
you have enterde valid ip adress

!Feel free to Ask
:)
Kuldeep