-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzmones_ENG.sh
85 lines (84 loc) · 1.6 KB
/
zmones_ENG.sh
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
ex=0
while [ $ex -eq 0 ]
do
dialog --title "List" --menu "Select item:" 0 0 5 \
Create_New_User "first name, last name, phone number, e-mail" \
Search_User_By_Name "by name" \
Users_List "All Person List" \
Delete_User "Delete By ID" \
Exit "Close Menu" 2>zmoness.txt
kint=$?
zms=$(cat zmoness.txt)
case $kint in
0) case $zms in
Create_New_User) dialog --inputbox \
"Enter name, image, phone number, email" 0 0 2>vardas.txt
vpte=$?
case $vpte in
0) if [ -s vardas.txt ]
then
cat vardas.txt >>telk.txt
echo "" >>telk.txt
fi;;
1);;
255);;
esac
;;
Search_User_By_Name) dialog --inputbox "Enter the name of the person you are looking for:" 0 0 2>iesk.txt
isk=$?
case $isk in
0) vard=$(cat iesk.txt)
grep "$vard" telk.txt > irasas.txt
if [ -s irasas.txt ]
then
dialog --msgbox "Post Found: $(cat irasas.txt)" 15 20
else
dialog --msgbox "Error" 5 20
fi;;
1);;
255) ;;
esac;;
Users_List)
if [ -s telk.txt ]
then
dialog --msgbox "Contacts List: $(cat -n telk.txt)" 100 100
else
dialog --msgbox "Error" 0 0
fi;;
Delete_User)
if [ -s telk.txt ]
then
dialog --inputbox "Enter the serial number of the contact to delete it : " 0 0 2>salin.txt
sal=$?
case $sal in
0) sali=$(cat salin.txt)
if [ -s salin.txt ]
then
dialog --yesno \
"Are you sure you want to delete $(head -n "$sali" telk.txt | tail -n 1) ?" 0 0
salin=$?
case $salin in
0)sed -i "$sali"'d' telk.txt;;
1);;
255);;
esac
else
dialog --msgbox "Please enter something " 0 0
fi;;
1);;
255);;
esac
else
dialog --msgbox "List Empty" 0 0
fi;;
Exit) ex=$(expr $ex + 1) ;;
esac;;
1)exit;;
255)exit;;
esac
rm -f salin.txt
rm -f vardas.txt
rm -f iesk.txt
rm -f irasas.txt
rm -f zmoness.txt
done