Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

shell script

[oracle@mac Desktop]$ ./top.sh
bash: ./top.sh: Permission denied
0
walkerdba
Asked:
walkerdba
  • 3
  • 3
  • 2
  • +2
1 Solution
 
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
 
slightwv (䄆 Netminder) Commented:
As johnsone pointed out... change the permissions:
chmod 750 top.sh

The alternative is force execution:
. ./top.sh
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
johnsoneSenior 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
 
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

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now