PDA

View Full Version : [ubuntu] [SOLVED] give script executable permission



mdewet
December 21st, 2008, 07:15 PM
hi

I'm quite new to hardy, and i'm trying out to write my own scripts. I've read the bash scripting tutorial at https://help.ubuntu.com/community/Beginners/BashScripting, but I still cant run the script.


muerte@muerte:~$ /home/muerte/scripts/toets.sh
bash: /home/muerte/scripts/toets.sh: Permission denied

I have done both

sudo chmod a+x /home/muerte/scripts

and


sudo chmod 700 /home/muerte/scripts

as prescribed by the tutorial to give the appropriate permissions, but it still gives me the permission denied error.

shredder12
December 21st, 2008, 07:17 PM
well try running..

sh script.sh
or

./script.sh

arckeda
December 21st, 2008, 07:18 PM
Your only giving the directory executable permissions. Make sure you put in the full path name of the script of something like:


sudo chmod a+x /directory/directory/*

albinootje
December 21st, 2008, 07:20 PM
I'm quite new to hardy, and i'm trying out to write my own scripts. I've read the bash scripting tutorial at https://help.ubuntu.com/community/Beginners/BashScripting, but I still cant run the script.


You should try :


chmod +x /home/muerte/scripts/toets.sh

and then :


./home/muerte/scripts/toets.sh

mdewet
December 21st, 2008, 07:34 PM
thanks for all the replies, I tried everything, still no luck..


You should try :


chmod +x /home/muerte/scripts/toets.sh

and then :


./home/muerte/scripts/toets.sh


after executing this I got this

muerte@muerte:~$ sudo chmod +x /home/muerte/scripts/toets.sh
muerte@muerte:~$ ./home/muerte/scripts/toets.sh
bash: ./home/muerte/scripts/toets.sh: No such file or directory


when I try to open /home/muerte/scripts in the file manager it refuses access to the folder, and when I opened the folder with nautilus the file is there

why do I all of the sudden get the no such file error?

albinootje
December 21st, 2008, 07:43 PM
when I try to open /home/muerte/scripts in the file manager it refuses access to the folder, and when I opened the folder with nautilus the file is there

why do I all of the sudden get the no such file error?

What do you mean with "the file manager" ?
In Ubuntu the default file manager is Nautilus.

It could be possible that "bash" does respond like that because of the content of your script.
And do you have a separate /home partition with noexec mount options ?
Probably not, but just wondering.

Can you copy your toets.sh to /tmp/ and then run :

sh /tmp/toets.sh

Dedoimedo
December 21st, 2008, 07:47 PM
Please enter the directory where the script is.

First, make sure you OWN it:



sudo chown your-user:you-user script-file


Example:


sudo chown roger:roger script.sh


Next, chmod it:



chmod +x script.sh


This is enough, as you own the script ...

Run it:



./script.sh


Dedoimedo

mdewet
December 21st, 2008, 07:51 PM
yes, that worked!..

I meant I couldn't view the contents of the folder when I tried Places > Home folder..I had to open nautilus from the terminal with

gksudo nautilus

thanks for the help! I will save all my future scripts in the /tmp folder

mdewet
December 21st, 2008, 07:54 PM
Please enter the directory where the script is.

First, make sure you OWN it:



sudo chown your-user:you-user script-file


Example:


sudo chown roger:roger script.sh


Next, chmod it:



chmod +x script.sh


This is enough, as you own the script ...

Run it:



./script.sh


Dedoimedo

This also works great!

Thanks for the help!

albinootje
December 21st, 2008, 08:31 PM
yes, that worked!..

cool :)


thanks for the help! I will save all my future scripts in the /tmp folder
If you want to save your scripts permanently, then /tmp is a bad idea because after each reboot it will be wiped.
(/tmp can sometime be handy to quickly test things, because it has 1777 permissions, and is used for temporary files by several programs anyway.)