1834349 Members
2322 Online
110066 Solutions
New Discussion

run scripts

 
SOLVED
Go to solution
Vogra
Regular Advisor

run scripts

Hi All!
what's I user need to do when I try to run a scripts and get the following error:
sh: ./test.sh: Execute permission denied.
We are spirits in the material world
14 REPLIES 14
Patrick Wallek
Honored Contributor
Solution

Re: run scripts

Make sure execute permission is set for the appropriate users. Depending on the script I usually set permission to 755 or 750 or 700.

Do a 'chmod u+x filename' so you can execute it yourself.
Joseph C. Denman
Honored Contributor

Re: run scripts

You do not have execution permission.

If you have write access to the file??

chmod 755 test.sh

...jcd...

If I had only read the instructions first??
Kevin Wright
Honored Contributor

Re: run scripts

chmod 777 test.sh should do it, but you may want to make it alittle more secure..755.
Praveen Bezawada
Respected Contributor

Re: run scripts

Hi
Without giving the execute permission for the script you can run it by

sh test.sh

PRB
Rita C Workman
Honored Contributor

Re: run scripts

If you have set the execute privileges for the file...I find that usually I forgot to make sure the directory(s) above the file has execute privileges too!

This is probably the error I make all too often....give the file 750 but gave the directory 760....

Regards,
Rita
Joseph C. Denman
Honored Contributor

Re: run scripts

I did not think the execute on a dir had anything to do with execution????

Without the x perm on a dir, you cant even cd to it.

...jcd...
If I had only read the instructions first??
Vogra
Regular Advisor

Re: run scripts

Ok All!
I did understand.
Now, my problem is... the user uzzz is trying to run a script with Cron and the following msg is displayed:
sh: ./_ora/exp1.sh: not found.
but I see de file in the specified dir.
???
We are spirits in the material world
someone_4
Honored Contributor

Re: run scripts

Hello
Make sure to use the full path of the script you are trying to run. For example if I have a script in /home/richard/scripts
called script1
in the script I would put
/home/richard/scripts/script1
not just
./script1

As I have learned paths are very important.
Here is a past post of mine where I had the same problem.
I qoute Mr. A. CLay
This may not be all be you get the idea, remember the cron environment is intentionally very sparse and stupid; you have to tell it everything. It can barely spell cron on its own.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x026746ff9277d511abcd0090277a778c,00.html

hope this helps

Richard




Kevin Wright
Honored Contributor

Re: run scripts

the absolute path must be specified
Bill Hassell
Honored Contributor

Re: run scripts

When creating cron jobs, it is very important to read the man page for cron where it talks about the environment. Bascially, it says you get almost nothing. cron does NOT login, it runs on the user's behalf but all those nice features like $PATH and other env setups will not take place. This is why the cron job runs fine when being tested from a login but fails when run by cron.

So good sysadmin practice for cron jobs is to write EVERY command with a leading / (also known as a full path as in /usr/bin/grep rather than just grep). This includes any references to files, and if one script calls another, every script involved must use full pathnames. Also, any special env setups (for example, Oracle) must be 'sourced' within the script.

Essentially, the cron job must explicitly setup everything that is done automatically by /etc/profile and .profile.


Bill Hassell, sysadmin
Vogra
Regular Advisor

Re: run scripts

Hi All!

after set the rights, the script is running, but the root mail is receiving the msg sh: ./test.sh: Execute permission denied.
???
We are spirits in the material world
someone_4
Honored Contributor

Re: run scripts

Is the full path in the cron script ?
Instead of ./test in your script do /home/whatever/scripts/test
and test has to have execute premissions.
Try chmod 777 test but this will make this script executable by everyone.


Richard
Deshpande Prashant
Honored Contributor

Re: run scripts

Hi
Instead of relative path use the absolute path for the script in cron.

Instead of ./test use //test
Use full path even for the commands in script test.

Also give execute permission for the script chmod 755 test.
Thanks.
Prashant.
Take it as it comes.
ajax13
Frequent Advisor

Re: run scripts

I am not sure if this will help, but if the script is running OK you could add this to the command you running in crontab
> /dev/null 2>&1
This stops mail going to root.

Thanks