Solved

shell script

Posted on 2013-06-04
10
256 Views
Last Modified: 2013-06-22
[oracle@mac Desktop]$ ./top.sh
bash: ./top.sh: Permission denied
0
Comment
Question by:walkerdba
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 34

Expert Comment

by:johnsone
Comment Utility
You don't have execute permission on top.sh.  You would need to change the permission with the chmod command.
0
 
LVL 6

Expert Comment

by:Robert Saylor
Comment Utility
do:
sudo sh top.sh

Open in new window


Then enter in the root password.
0
 
LVL 76

Expert Comment

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

The alternative is force execution:
. ./top.sh
0
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
Comment Utility
. ./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
 
LVL 35

Expert Comment

by:YZlat
Comment Utility
try

chmod 0744 top.sh

Open in new window


or

chmod go+rx top.sh

Open in new window

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
 
LVL 6

Expert Comment

by:Robert Saylor
Comment Utility
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
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
>>The issue is the user does not have access to sh.

I think I have to disagree.  What are you basing this on?
0
 
LVL 6

Expert Comment

by:Robert Saylor
Comment Utility
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
 

Author Closing Comment

by:walkerdba
Comment Utility
yes
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now