Shell Scripting

Asked by zelenytsya on 2012-05-07

I read http://rute.2038bug.com/node10.html.gz#SECTION001030000000000000000
I Created a new script called "backup-lots.sh", containing:

#!/bin/sh
 for i in 0 1 2 3 4 5 6 7 8 9 ; do
     cp $1 $1.BAK-$i done

And create a file "important_data" with anything in it and then run:

petro-z@petro-z-desktop:~$ ./backup-lots.sh important_data
bash: ./backup-lots.sh: Отказано в доступе

or

petro-z@petro-z-desktop:~$ sudo ./backup-lots.sh important_data
sudo: ./backup-lots.sh: command not found

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2012-05-08
Last query:
2012-05-08
Last reply:
2012-05-07
Best Manfred Hampl (m-hampl) said : #1

You have to change the file protection to make the file "executable"

chmod u+x ./backup-lots.sh

Jeet (gour-jitendrasingh) said : #2

first change permission of file

chmod 777 backup-lots.sh (it will give all permission to file)

then run script using

./backup-lots.sh

thanks

zelenytsya (petro-z) said : #3

Thanks Manfred Hampl, that solved my question.