LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why do I get a permission denied from a script ? (https://www.linuxquestions.org/questions/linux-newbie-8/why-do-i-get-a-permission-denied-from-a-script-915024/)

Glenn D. 11-23-2011 12:28 AM

Why do I get a permission denied from a script ?
 
Hello,
Why do I get a permission denied from a script ?
Thanks Glenn

Using openSUSE 12.1 64 bit
Sequence of steps:

# id
uid=0(root) gid=0(root) groups=0(root)

# ll
total 8
drwxr-xr-x 2 root root 40 Nov 23 14:09 disk
drwxr-xr-x 2 root root 40 Nov 23 14:09 disk2
-rwx------ 1 root root 29 Nov 23 14:22 off
-rwx------ 1 root root 39 Nov 23 17:20 on


# cat on
#!/bin/sh
mount /dev/sdb6 /media/disk

# chmod 700 on

# ./on
bash: ./on: Permission denied


# dmesg
.
.
.
[ 2858.804066] REISERFS (device sdb6): found reiserfs format "3.6" with standard journal
[ 2858.804111] REISERFS (device sdb6): using ordered data mode
[ 2858.817790] REISERFS (device sdb6): journal params: device sdb6, size 8192, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30
[ 2858.819147] REISERFS (device sdb6): checking transaction log (sdb6)
[ 2858.874905] REISERFS (device sdb6): Using r5 hash to sort names

ukiuki 11-23-2011 12:31 AM

Try 755 instead.

Telengard 11-23-2011 10:12 AM

Quote:

Originally Posted by ukiuki (Post 4531314)
Try 755 instead.

Why would this work? If owner (root in this case) has execute perm, then why does the group bit matter?

I tried creating a script with 700 perm and was able to execute it.

rknichols 11-23-2011 12:07 PM

Auto-mounting of file systems under /media typically includes the "noexec" option. Try
Code:

mount -o remount,exec /media/disk
Since it's a script, you can also run it by invoking the shell directly:
Code:

sh ./on
For that case, only read permission is needed.

gary185 11-23-2011 01:51 PM

try moving the script to your home directory.
i never have figured out why but scripts won't
run from a disk like that.


All times are GMT -5. The time now is 11:51 PM.