Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

shell script

Posted on 2013-06-04
10
Medium Priority
?
269 Views
Last Modified: 2013-06-22
[oracle@mac Desktop]$ ./top.sh
bash: ./top.sh: Permission denied
0
Comment
Question by:walkerdba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 35

Expert Comment

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

Expert Comment

by:Robert Saylor
ID: 39219709
do:
sudo sh top.sh

Open in new window


Then enter in the root password.
0
 
LVL 77

Expert Comment

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

The alternative is force execution:
. ./top.sh
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 35

Accepted Solution

by:
johnsone earned 2000 total points
ID: 39219760
. ./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
ID: 39219891
try

chmod 0744 top.sh

Open in new window


or

chmod go+rx top.sh

Open in new window

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39219896
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 7

Expert Comment

by:Robert Saylor
ID: 39219897
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 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39219901
>>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 7

Expert Comment

by:Robert Saylor
ID: 39219924
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
ID: 39267695
yes
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

715 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