-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpermissions
116 lines (116 loc) · 2.63 KB
/
permissions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
echo "Enter the name of the file to modify its permissions"
read fileName
if test -f $fileName
then
cont=0
quantity=0
while [ $cont -lt 3 ]
do
if test $cont -eq 0
then
control="Owner"
elif test $cont -eq 1
then
control="Group"
else
control="Others"
fi
clear
echo "_________________________________________"
echo "| |"
echo "|| Manage "$control" permissions ||"
echo "|| ||"
echo "|| 1. Only executable ||"
echo "|| 2. Only writing ||"
echo "|| 3. Writing and executable ||"
echo "|| 4. Only reading ||"
echo "|| 5. Reading and executable ||"
echo "|| 6. Reading and writing ||"
echo "|| 7. Reading, writing and executable ||"
echo "|| 8. Nothing ||"
echo "|_______________________________________|"
read option
case $option in
1)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 100 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 10 ))
else
quantity=$(( $quantity + 1 ))
fi;;
2)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 200 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 20 ))
else
quantity=$(( $quantity + 2 ))
fi;;
3)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 300 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 30 ))
else
quantity=$(( $quantity + 3 ))
fi;;
4)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 400 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 40 ))
else
quantity=$(( $quantity + 4 ))
fi;;
5)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 500 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 50 ))
else
quantity=$(( $quantity + 5 ))
fi;;
6)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 600 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 60 ))
else
quantity=$(( $quantity + 6 ))
fi;;
7)cont=$(( $cont + 1 ));
if test $cont -eq 1
then
quantity=$(( $quantity + 700 ))
elif test $cont -eq 2
then
quantity=$(( $quantity + 70 ))
else
quantity=$(( $quantity + 7 ))
fi;;
8)cont=$(( $cont + 1 ));;
*)echo "Typing error"; sleep 1;;
esac
done
chmod $quantity $fileName
echo "The file $fileName has been modified its permissions correctly"
echo "Press ENTER to continue"
read nothing
else
echo "Error, The file $fileName doesn't exist"
sleep 1
fi
sh files