shell学生信息管理.docx
《shell学生信息管理.docx》由会员分享,可在线阅读,更多相关《shell学生信息管理.docx(8页珍藏版)》请在冰豆网上搜索。
shell学生信息管理
insert_s()
{
file_name="/root/aillo/students.db"
dialog--title"Student:
Insertarecord"--inputbox"Pleaseinputthestudent'sinformationinthesort:
(id,name,college):
"20502>tmp.txt
content=$(cattmp.txt)
IFS=","
readsidsnamesinunsetIFS
grep-c"$sid"$file_name>menu.txt
sid=$(catmenu.txt)
if["$sid"!
="0"];then
dialog--title"ERROR"--msgbox"Recordhasexisted!
"2030
else
echo"$content">>$file_name
dialog--title"ReplyInfo"--msgbox"Addsuccessfully!
"1030
fi
}
insert_c()
{
file_name="/root/aillo/colleges.db"
dialog--title"College:
Insertarecord"--inputbox"Pleaseinputthecollege'sinformationinthesort(cid,cname):
"20502>tmp.txt
content=$(cattmp.txt)
IFS=","
readcidcnameunsetIFS
grep-c"$cid"$file_name>tmp.txt
cid=$(cattmp.txt)
if["$cid"!
="0"];then
dialog--title"ERROR"--msgbox"Recordhasexisted!
"3050
else
echo"$content">>$file_name
dialog--title"ReplyInfo"--msgbox"Addsuccessfully!
"1030
fi
}
delete_s()
{file_name="/root/aillo/students.db"
dialog--title"Student:
Deletearecord"--inputbox"PleaseinputtheIDofthestudentyouwanttodelete:
"20502>tmp.txt
readsidgrep-v$sid$file_name>tmp.txt
mvtmp.txt$file_name
dialog--title"ReplyInfo"--msgbox"therecordhasbeendelete!
"1030
}
delete_c()
{file_name="/root/aillo/colleges.db"
dialog--title"College:
Deletearecord"--inputbox"PleaseinputtheIDofthecollegeyouwanttodelete:
"20502>tmp.txt
readcidgrep-v$cid$file_name>tmp.txt
mvtmp.txt$file_name
dialog--title"ReplyInfo"--msgbox"therecordhasbeendelete!
"1030
}
display_s()
{file_name="/root/aillo/students.db"
cat$file_name|whilereadline
do
echo$line>tmp.txt
IFS=","
readsidsnamesinecho"sid:
$sid">>t.txt
echo"sname:
$sname">>t.txt
echo"sin:
$sin">>t.txt
echo"---------------------">>t.txt
IFS=""
done
content=$(catt.txt)
dialog--title"AllStudents'Info"--msgbox"$content"5050
rmt.txt
}
display_c()
{file_name="/root/aillo/colleges.db"
cat$file_name|whilereadline
do
echo$line>tmp.txt
IFS=","
readcidcnameecho"cid:
$cid">>t.txt
echo"cname:
$cname">>t.txt
echo"---------------------">>t.txt
IFS=""
done
content=$(catt.txt)
dialog--title"Allcolleges'Info"--msgbox"$content"5050
rmt.txt
}
count()
{
file_name="/root/aillo/students.db"
dialog--title"Count"--inputbox"Pleaseinputtheidofcollegestudentsyouwanttocount:
"20502>tmp.txt
readp1dialog--title"ReplyInfo"--msgbox"Thereare`grep-c$p1$file_name`studentsinthe$p1college!
"1030
}
change_s()
{
file_name="/root/aillo/students.db"
dialog--title"ModifyStudent'sInfo"--inputbox"Pleaseinputthenewinformationyouwanttomodifyinthesort(sid,sname,sin):
"20502>tmp.txt
IFS=","
readp1p2p3grep-v$p1$file_name>tmp.txt
echo"$p1,$p2,$p3">>tmp.txt
IFS=""
mvtmp.txt$file_name
dialog--title"ReplyInfo"--msgbox"Theinformationhasbeenmodified!
"1030
}
change_c()
{
file_name="/root/aillo/colleges.db"
dialog--title"ModifyCollege'sInfo"--inputbox"Pleaseinputthenewinformation:
"20502>tmp.txt
IFS=","
readp1p2grep-v$p1$file_name>tmp.txt
echo"$p1,$p2">>tmp.txt
IFS=""
mvtmp.txt$file_name
dialog--title"ReplyInfo"--msgbox"Theinformationhasbeenmodified!
"1030
}
status=1
dialog--title"Students'InfoManageSystem"--msgbox"\\nWelccometousetheSystem!
\\n"1035
if[$?
!
=0];then
sleep1
dialog--clear
exit0
fi
while["$status"="1"]
do
dialog--title"MainMenu"--menu"Choices"152021"Student"2"College"2>tmp.txt
MY_CHOICE=$(cattmp.txt)
if[$?
!
=0];then
sleep1
dialog--clear
exit0
fi
if["$MY_CHOICE"="1"];then
dialog--title"StudentInfoManage"--menu"ChooseOperation"203071"INSERT"2"DELETE"3"MODIFY"4"COUNT"5"DISPLAY"6"BACK"7"EXIT"2>tmp.txt
if[$?
!
=0];then
sleep1
dialog--clear
exit0
fi
choice_2=$(cattmp.txt)
if["$choice_2"="1"];then
insert_s
elif["$choice_2"="2"];then
delete_s
elif["$choice_2"="3"];then
change_s
elif["$choice_2"="4"];then
count
elif["$choice_2"="5"];then
display_s
elif["$choice_2"="6"];then
continue
else
break
fi
else
dialog--title"CollegeInfoManage"--menu"ChooseOperation"203071"INSERT"2"DELETE"3"MODIFY"4"COUNT"5"DISPLAY"6"BACK"7"EXIT"2>tmp.txt
if[$?
!
=0];then
sleep1
dialog--clear
exit0
fi
choice_2=$(cattmp.txt)
if["$choice_2"="1"];then
insert_c
elif["$choice_2"="2"];then
delete_c
elif["$choice_2"="3"];then
change_c
elif["$choice_2"="4"];then
count
elif["$choice_2"="5"];then
display_c
elif["$choice_2"="6"];then
continue
else
break
fi
fi
dialog--yesno"Doyouwanttocontinue?
"1020
if[$?
=0];then
status=1
else
status=0
fi
done
sleep1
dialog--clear
exit0