shell script

[oracle@mac Desktop]$ ./top.sh
bash: ./top.sh: Permission denied
walkerdbaAsked:
Who is Participating?
 
johnsoneConnect With a Mentor Senior Oracle DBACommented:
. ./top.sh does not force execution.  That runs the commands in the current process (shell)  and does not fork a new process.  If your current shell is different than the shell that top.sh expects to run then errors could occur.

Depending on what you are doing in your script, this could also have unintended consequences in the original process as well.  In my opinion, only scripts that set environment variables should be run this way.
0
 
johnsoneSenior Oracle DBACommented:
You don't have execute permission on top.sh.  You would need to change the permission with the chmod command.
0
 
Robert SaylorSenior DeveloperCommented:
do:
sudo sh top.sh

Open in new window


Then enter in the root password.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
slightwv (䄆 Netminder) Commented:
As johnsone pointed out... change the permissions:
chmod 750 top.sh

The alternative is force execution:
. ./top.sh
0
 
YZlatCommented:
try

chmod 0744 top.sh

Open in new window


or

chmod go+rx top.sh

Open in new window

0
 
slightwv (䄆 Netminder) Commented:
Maybe force was a poor choice of words.  I meant that it would execute a script that did not necessarily have execute permission on it.

I do agree with your other comments.

>>chmod 0744 top.sh

I would not give World execute on any script, ever.
0
 
Robert SaylorSenior DeveloperCommented:
The issue is the user does not have access to sh. The user would need to be added to the same group that sh has.

root@linux [~]# ls -lha /bin/sh
lrwxrwxrwx 1 root root 4 Sep 14  2011 /bin/sh -> bash*

Open in new window


The fix should be to execute chmod 755 /bin/sh so sh will have group execute.
0
 
slightwv (䄆 Netminder) Commented:
>>The issue is the user does not have access to sh.

I think I have to disagree.  What are you basing this on?
0
 
Robert SaylorSenior DeveloperCommented:
sorry, yes you were correct. I just simulated it on my server.

mine@**** [~]# ./test.sh
-bash: ./test.sh: Permission denied
mine@**** [~]# sh test.sh
test
mine@**** [~]# chmod 755 test.sh
mine@**** [~]# ./test.sh
test
mine@**** [~]#
0
 
walkerdbaAuthor Commented:
yes
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.