Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am running a script on arm target board as a super user, i.e., as a root user. But the script is not executing if i run it with following syntax

root@freescale$ ./Script.sh 
-sh: ./Script.sh: Permission denied

I already gave the read and execute permissions(+rx) by using chmod command. On executing "ls -l" command I get following attributes

root@freescale$ ls -l | grep Script.sh
-rw-rw-rw-    1 root     root          362 Jul  2 08:47 Script.sh

"x" is not there in the file attributes column, whereas the chmod command executed successfully. On the other hand, this script runs when I run it as

root@freescale$ sh Script.sh 

Can anyone help me to answer this situation?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

even if your "chmod" returns success, the execute bit does not really get turned on, as "ls" shows, therefore I conclude something is transparently preventing you from changing the file mode on the filesystem.

what does "lsattr Script.sh" shows?

can you put the script into a ramdrive or another filesystem on the same host and try again?

share|improve this answer
    
It gives following error : lsattr: Inappropriate ioctl for device While reading flags on Script.sh –  pRAShANT Jul 2 '13 at 9:29
    
what filesystem is Script.sh stored on? see the second question I've asked, too –  Costin Gușă Jul 2 '13 at 9:33
    
Well, I have placed it on a flash drive (type vfat) and mounted on /mnt partition. And the rootfs I am using is UBIFS. I am running it directly from the flash drive.On other system it runs fine without any issue –  pRAShANT Jul 2 '13 at 9:44
    
This subject has been discussed here and here. It seems impossible to execute script from such a device. Perhaps take a look at the post mentioning mount with exec in the second thread. –  ssssteffff Jul 2 '13 at 9:48
    
what is the output of "mount" command? –  Costin Gușă Jul 2 '13 at 9:51

Your script does not have the "execute" rights set for anybody. Try:

chmod u+x Script.sh

and the owner of the file should be able to start it with ./Script.sh

Similarly,

chmod g+x Script.sh
chmod o+x Script.sh

work if you want the group (g) or anybody (o) to be allowed to execute it.

share|improve this answer
    
I tried it but its still the same, no change –  pRAShANT Jul 2 '13 at 9:34

The file has to be "executable" in order to be executed using ./Script.sh.

Use chmod +x Script.sh to add the "execute" flag for this file.

EDIT

Sorry, I missed an important detail in your post, you already did that, but did not work... try executing chmod again, then immediately execute echo $? to get the exit status, it may be help.

share|improve this answer
    
I got success status (i.e 0) on performing echo $? –  pRAShANT Jul 2 '13 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.