3

I am running a shell script(Script.sh) which, itself, is calling other shell scripts( Script2.sh, Script3.sh ...etc). I logged in as a root user and have given execution permission to all the scripts. But on when I execute "ls -l" the scripts still dont have execution permissions displayed on file attributes column. "Script.sh" runs by following syntax:

root@freescale $ sh Script.sh 

But this script is not able to execute other scripts(Script2.sh, Script3.sh) being called by it. Error is reported as "Permission denied"

I already gave execution permission by chmod command but then also neither the permissions are changing nor the scripts(Script2.sh, Script3.sh ..) are executing.

I hope this error is due to the reason that Script2.sh are called in Script3.sh as:

./Script2.sh ./Script3.sh 

And if I write it as : sh Script2.sh It executes but doesn't able to execute other script which are called inside Script2.sh and reports same error as "Permission Denied"

7
  • Hard to tell without seeing the scripts. Can you show a "sscce.org" Commented Jul 2, 2013 at 9:49
  • What was the chmod command you used? You need to set the execute bit on the scripts. Commented Jul 2, 2013 at 9:53
  • probably you have your scripts located on a partition mounted with the "noexec" flag set. Commented Jul 2, 2013 at 9:53
  • in addition to devnull's remark, what's the exact output of ls -l Script*? Commented Jul 2, 2013 at 9:54
  • @umlaeute: correct!!! Thanks dude, actually the scripts were on a flash drive and noexec flag was set for it. But if this case is there, why its running by root@freescale$ sh Script.sh Commented Jul 2, 2013 at 10:07

2 Answers 2

7

Make sure that your partition is not mounted with the noexec flag (which - as the name suggests - prevents making any files executable)

Sign up to request clarification or add additional context in comments.

Comments

1

Kindly make sure the permission and ownership for the script.sh file, also try

 # chmod 755 script.sh # chown root.root script.sh 

Thanks.

3 Comments

@Sonny: the difference between chmod u+x script.sh and chmod 0755 script.sh; chown root.root is the with the former, you only ensure that the user can execute the script, while the latter makes sure that everybody can execute it and only the root user can modify it.
In the general case, reassigning ownership is probably neither correct nor necessary.
Beware of the form "chown root.root ...": not all the systems accept that dot.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.