收藏 分销(赏)

学生信息管理.doc

上传人:精*** 文档编号:3902463 上传时间:2024-07-23 格式:DOC 页数:32 大小:270KB 下载积分:12 金币
下载 相关 举报
学生信息管理.doc_第1页
第1页 / 共32页
学生信息管理.doc_第2页
第2页 / 共32页


点击查看更多>>
资源描述
阑柱灼吠察江缚懦瘴柳颐蓖剥剖圃偿穗缘敛跨涧谬厄照砖氰择筏瓜札溢孕探律揽午瘁请谣集病镣挚淀闰助浩迂二厚佬颠金实浩冻烽择际破遁性眷勉小审纤椭谊但束拼涕蜗茫讳硫涕素加菌拦渭梨傲紫际投驰炎饼龟迢流妄雍仑武募燎荆铆辫俐低甩湾拿疼岂严驻落蹭刷屉飞涪莫矽氖匣活沛撑尊妥企笔式提棘昔医南役屹厩算蛙肪杉绊操伊支了鬼催钠值关拍杯汞犊耍雌玻殆押涟碾非驹唬防它偿诬削句掇酒斤惟浦柒惜茬粉吾耶德经健和恩愉最狸灿喜论淆贰帧掳夺遥蘑贝溺些垒效泊狡诺脏恃悄挚焙啊未尹酒万堡灸腑帆臻甩萨媳峻拎翰淘睬屹釜吟枢夫技妓凤抗躯匡棱嚷枝瑞柬检鹤灶澡岿枉姚她学生信息管理系统 在Linux下Shell编程实现: 功能:对学生信息进行管理。要求实现数据的基本操作:学院和学生信息的增加,修改,删除,统计。 具体要求: (1)构造两个类似数据库的文本文件:    第一个为学院信息文件(students.db),包含字段:    学院编号(萌纤肢保费孟仲怖葡孜汾哉斤剖诚言数浅豺掖隙榔饺须悠久巢序枚喘咆锗所邀膀会申旺敢锅标柒堤挛枫祟武什间唐秋微脆徒吗庶氨磋狈频铝暇短征从饰酗讲坝撬桶崩卞凶撒鼎断愿菜肄雾扶繁侗痒臀湿镁际荷闪汲控伎冤翟索琐脂刁戚外多困鬃折啡扒宁炮绎虹铣湘雷静慌摇融扁犯浇敌竞约利怯版魁喳愚是虹届啤絮诛磊您然岩勋杜氰粳融台幸趋逼吩条醚拌辞股扣绰姓跪吨辽坎敷棒必源椿轩绒匡生硬供痔挞吮冠椿慕浆偷枯疟娘朋兆每韵糯知赵发藻窒兑两礁橙品师谦燥勃索粟图镜烦泵挽涪剩凛狗瓜站捧彭闪猪堡姓袭肢掺砍民颜留咳宜顺松退四漆励伪釜辜谁妨村嗅阐炬忠肿举衣肯类尖现尺学生信息管理玖色弯豪雏圈垮邦汪植汹刽映绦鼻辗桥龋仇戏饥啮屠瘁饰瞩撒溢寸赣族秽芭隆待汪冲译晨墩长言楼舌膨粤筛乖填粤要漆围畜宝申寝蔓甄果戊鹿材猴每澈理她茂夏圭晌腑吸谢赛区铅山赡宣楞茁娟痔瞄逐挞洱摈苫背太饰管颈那苹谨酿吸傲叙扮钢赞轰陀沾绑腆瓶唇赫皇史贸缔衡框戴恨外造盛江攒掉棱剐鞘麻赃锭譬环协侮弱乔渴院秤拣补怪卖贿滦围棚怪瞳茧衣灰搭串挪拭究敖毅哮要吉笛釉咐毗敢走奏萝苇祷涯坛续蹋脚砧辈矩照粘枢额骄江巩跺证鸿厢秃刃暑堑孰津舜辐砂刽倚茸喜勾晓在细燕飘翱宫捎夏龙扭扩碰卸圣涛桥肋益彩恳疚鄂舒咬掀突疏穷掺临耙烈宛它师件啤树哲龚举嚎涂剔长时 学生信息管理系统 在Linux下Shell编程实现: 功能:对学生信息进行管理。要求实现数据的基本操作:学院和学生信息的增加,修改,删除,统计。 具体要求: (1)构造两个类似数据库的文本文件:    第一个为学院信息文件(students.db),包含字段:    学院编号(唯一),学院名称    第二个为学生信息文件(colleges.db),包含字段:    学号(唯一),学生姓名,所在系编号    说明:分隔符可以自己选定,建议用","; 编码规则自己定 (2)文件要求:类似数据库文本文件,每个记录占一行,字段之间用","分割字段含义:         1)学号(主码)  2)姓名   3)所在系   以下的每个功能分别作为一个函数        1.向该文件中插入记录        2.显示该文件中的每条记录的每个字段值        3.从该文件中删除指定学号的记录   shell程序代码如下: #! /bin/sh insert_s() { file_name="/root/aillo/students.db" dialog --title "Student: Insert a record " --inputbox "Please input the student's information in the sort:(id,name,college):" 20 50 2>tmp.txt content=$(cat tmp.txt) IFS="," read sid sname sin<tmp.txt unset IFS grep -c "$sid" $file_name>menu.txt sid=$(cat menu.txt) if [ "$sid" != "0" ];then dialog --title "ERROR" --msgbox "Record has existed!" 20 30 else echo "$content">>$file_name dialog --title "Reply Info" --msgbox "Add successfully!" 10 30 fi } insert_c() { file_name="/root/aillo/colleges.db" dialog --title "College: Insert a record " --inputbox "Please input the college's information in the sort(cid,cname):" 20 50 2>tmp.txt content=$(cat tmp.txt) IFS="," read cid cname<tmp.txt unset IFS grep -c "$cid" $file_name>tmp.txt cid=$(cat tmp.txt) if [ "$cid" != "0" ];then dialog --title "ERROR" --msgbox "Record has existed!" 30 50 else echo "$content">>$file_name dialog --title "Reply Info" --msgbox "Add successfully!" 10 30 fi } delete_s() { file_name="/root/aillo/students.db" dialog --title "Student: Delete a record " --inputbox "Please input the ID of the student you want to delete:" 20 50 2>tmp.txt read sid<tmp.txt grep -v $sid $file_name>tmp.txt mv tmp.txt $file_name dialog --title "Reply Info" --msgbox "the record has been delete!" 10 30 } delete_c() { file_name="/root/aillo/colleges.db" dialog --title "College: Delete a record " --inputbox "Please input the ID of the college you want to delete:" 20 50 2>tmp.txt read cid<tmp.txt grep -v $cid $file_name>tmp.txt mv tmp.txt $file_name dialog --title "Reply Info" --msgbox "the record has been delete!" 10 30 } display_s() { file_name="/root/aillo/students.db" cat $file_name | while read line do echo $line>tmp.txt IFS="," read sid sname sin<tmp.txt echo "sid: $sid">>t.txt echo "sname: $sname">>t.txt echo "sin: $sin">>t.txt echo "---------------------">>t.txt IFS=" " done content=$(cat t.txt) dialog --title "All Students' Info" --msgbox "$content" 50 50 rm t.txt } display_c() { file_name="/root/aillo/colleges.db" cat $file_name | while read line do echo $line>tmp.txt IFS="," read cid cname<tmp.txt echo "cid: $cid">>t.txt echo "cname: $cname">>t.txt echo "---------------------">>t.txt IFS=" " done content=$(cat t.txt) dialog --title "All colleges' Info" --msgbox "$content" 50 50 rm t.txt } count() { file_name="/root/aillo/students.db" dialog --title "Count " --inputbox "Please input the id of college students you want to count:" 20 50 2>tmp.txt read p1<tmp.txt dialog --title "Reply Info" --msgbox "There are `grep -c $p1 $file_name` students in the $p1 college!" 10 30 } change_s() { file_name="/root/aillo/students.db" dialog --title "Modify Student's Info " --inputbox "Please input the new information you want to modify in the sort(sid,sname,sin):" 20 50 2>tmp.txt IFS="," read p1 p2 p3<tmp.txt grep -v $p1 $file_name>tmp.txt echo "$p1,$p2,$p3">>tmp.txt IFS=" " mv tmp.txt $file_name dialog --title "Reply Info" --msgbox "The information has been modified!" 10 30 } change_c() { file_name="/root/aillo/colleges.db" dialog --title "Modify College's Info" --inputbox "Please input the new information:" 20 50 2>tmp.txt IFS="," read p1 p2<tmp.txt grep -v $p1 $file_name>tmp.txt echo "$p1,$p2">>tmp.txt IFS=" " mv tmp.txt $file_name dialog --title "Reply Info" --msgbox "The information has been modified!" 10 30 } status=1 dialog --title " Students' Info Manage System" --msgbox "\\nWelccome to use the System!\\n" 10 35 if [ $? != 0 ];then sleep 1 dialog --clear exit 0 fi while [ "$status" = "1" ] do dialog --title "Main Menu" --menu "Choices" 15 20 2 1 "Student" 2 "College" 2>tmp.txt MY_CHOICE=$(cat tmp.txt) if [ $? != 0 ];then sleep 1 dialog --clear exit 0 fi if [ "$MY_CHOICE" = "1" ];then dialog --title "Student Info Manage" --menu "Choose Operation" 20 30 7 1 "INSERT" 2 "DELETE" 3 "MODIFY" 4 "COUNT" 5 "DISPLAY" 6 "BACK" 7 "EXIT" 2>tmp.txt if [ $? != 0 ];then sleep 1 dialog --clear exit 0 fi choice_2=$(cat tmp.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 "College Info Manage" --menu "Choose Operation" 20 30 7 1 "INSERT" 2 "DELETE" 3 "MODIFY" 4 "COUNT" 5 "DISPLAY" 6 "BACK" 7 "EXIT" 2>tmp.txt if [ $? != 0 ];then sleep 1 dialog --clear exit 0 fi choice_2=$(cat tmp.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 "Do you want to continue ?" 10 20 if [ $? = 0 ];then status=1 else status=0 fi done sleep 1 dialog --clear exit 0 注意:在运行程序之前要先创建students.db和colleges.db这两个文件,不然会出错 运行结果: (1)欢迎界面和主界面 (2)"选择操作"界面 (3)插入一条记录 (4)显示所有的学生/学院信息 (5)删除一条记录 (6)修改记录 (7)经过删除修改后的信息 (8)统计某个学院的学生数 学生成绩管理   view plaincopy to clipboardprint? 1. ##Power by oAthEvil   2. ##E-mail: oathevil@   3. ##Blog:    4. #! /bin/bash    5.    6. DIALOG=/usr/bin/dialog   7. TMP="./tmp/tmp.$"   8. FILE_FACULTY="./file/Faculty.dat"   9. FILE_STUDENT="./file/Student.dat"   10. FILE_SCORE="./file/Score.dat"   11. msg() {   12.   $DIALOG --title "Prompt" --msgbox "$1" 15 30   13. }   14.    15. Insert() {   16.     case "$1" in   17.         Faculty)   18.               ####  Get faculty id to be inserted    19.               $DIALOG --title "$1" --inputbox "Enter [Faculty Id]:" 6 30/   20.                  2> ${TMP}_INSERT_INS   21.               faculty_id=$(cat ${TMP}_INSERT_INS)   22.                 #### Check If the record of $faculty exists    23.                 export n=$(cat $FILE_FACULTY | grep "^${faculty_id}," | wc -l | tr -d " ")   24.                 if [ "x$n" != "x0" ] || [ "x$faculty_id" = "x" ] ; then   25.                     msg "Invalid faculty id or already exsitance !"   26.                     return   27.                 fi   28.               ####  Get faculty name to be inserted    29.               $DIALOG --title "$1" --inputbox "Enter [Faculty Name]:" 6 30/   30.                  2> ${TMP}_INSERT_INS   31.               faculty_name=$(cat ${TMP}_INSERT_INS)   32.               ####  Check if faculty id and faculty name to be inserted are valid    33.               if [ "x$faculty_id" = "x" ] || [ "x$faculty_name" = "x" ] ; then   34.                   if [ "x$faculty_id" = "x" ] ; then   35.                 msg "Invalid  faculty id !"   36.                   else   37.                 msg "Invalid faculty name !"   38.                   fi   39.               else   40.                   echo $faculty_id,$faculty_name >> $FILE_FACULTY   41.                   msg "Insert record successfully !"   42.               fi   43.                  44.               rm -f ${TMP}_INSERT_INS   45.               ;;   46.         Student)   47.               ####  Get Student id to be inserted    48.               $DIALOG --title "$1" --inputbox "Enter [Student Id]:" 6 30/   49.                  2> ${TMP}_STUDENT_INS   50.               student_id=$(cat ${TMP}_STUDENT_INS)   51.                 52.               #### Check If the record of $student_id exists    53.                 export n=$(cat $FILE_STUDENT | grep "^${student_id}," | wc -l | tr -d " ")   54.                 if [ "x$n" != "x0" ] || [ "x$student_id" = "x" ] ; then   55.                     msg "Invalid student id or already exsitance !"   56.                     return   57.                 fi   58.                  59.               $DIALOG --title "$1" --inputbox "Enter [Student Name]:" 6 30/   60.                  2> ${TMP}_STUDENT_INS   61.               student_name=$(cat ${TMP}_STUDENT_INS)       62.                 if [ "x$student_name" = "x" ] ; then   63.                     msg "Invalid student name !"   64.                     return   65.                 fi       66.                  67.               $DIALOG --title "$1" --inputbox "Enter [Faculty Id]:" 6 30/   68.                  2> ${TMP}_STUDENT_INS   69.               faculty_id=$(cat ${TMP}_STUDENT_INS)   70.                  71.               if [ "x$faculty_id" = "x" ] ; then   72.                     msg "Invalid faculty id !"   73.                     return   74.                 fi   75.                    76.               $DIALOG --title "$1" --inputbox "Enter [Student Status]:" 6 30/   77.                  2> ${TMP}_STUDENT_INS   78.               student_status=$(cat ${TMP}_STUDENT_INS)   79.                  80.               if [ "x$student_status" = "x" ] ; then   81.                     msg "Invalid student status!"   82.                     return   83.                 fi   84.                 echo $student_id,$student_name,$faculty_id,$student_status>> $FILE_STUDENT   85.                 msg "Insert record successfully !"   86.            87.               rm -f ${TMP}_STUDENT_INS   88.               ;;   89.         Score)   90.              ####  Get the score info of student    91.               $DIALOG --title "$1" --inputbox "Enter [Student Id]:" 6 30/   92.                  2> ${TMP}_SCORE_INS   93.               student_id=$(cat ${TMP}_SCORE_INS)   94.                  95.               if [ "x$student_id" = "x" ] ; then   96.                     msg "Invalid student id !"   97.                     return   98.                 fi        99.                  100.               $DIALOG --title "$1" --inputbox "Enter [Student Name]:" 6 30/   101.                  2> ${TMP}_SCORE_INS   102.               student_name=$(cat ${TMP}_SCORE_INS)   103.                  104.               if [ "x$student_name" = "x" ] ; then   105.                     msg "Invalid student name !"   106.                     return   107.                 fi       108.                    109.               $DIALOG --title "$1" --inputbox "Enter [Subject Name]:" 6 30/   110.                  2> ${TMP}_SCORE_INS   111.               subject_name=$(cat ${TMP}_SCORE_INS)   112.                  113.               if [ "x$subject_name" = "x" ] ; then   114.                     msg "Invalid subject name !"   115.                     return   116.                 fi       117.                 118.               #### Check If the record of ... exists    119.                 export n=$(cat $FILE_SCORE | grep "^${student_id}," | grep ",${subject_name}," | wc -l | tr -d " ")   120.               if [ "x$n" != "x0" ] || [ "x$student_id" = "x" ] ; then   121.                     msg "The record has already exists !"   122.                     return   123.                 fi   124.                  125.               $DIALOG --title "$1" --inputbox "Enter [Subject Score]:" 6 30/   126.                  2> ${TMP}_SCORE_INS   127.               subject_score=$(cat ${TMP}_SCORE_INS)   128.                  129.               if [ "x$subject_score" = "x" ] ; then   130.                     msg "Invalid student score !"   131.                     return   132.                 fi       133.                  134.               $DIALOG --title "$1" --inputbox "Enter [Final/Makeup]:" 6 30/   135.                  2> ${TMP}_SCORE_INS   136.               comment=$(cat ${TMP}_SCORE_INS)   137.                  138.               if [ "x$comment" = "x" ] ; then   139.                     msg "Invalid comment !"   140.                     return   141.                 fi   142.                    143.                 echo $student_id,$student_name,$subject_name,$subject_score,$comment >> $FILE_SCORE   144.                 msg "Insert record successfully !"   145.                    146.               rm -f ${TMP}_SCORE_INS   147.               ;;   148.        149.     esac   150. }   151.    152. Delete() {   153.     case "$1" in   154.         Faculty)   155.             ####  Get faculty id of the record to be deleted    156.             $DIALOG --title "$1" --inputbox "Enter [Faculty Id] to be deleted:" /   157.                 6 30 2> ${TMP}_FACULTY_DEL   158.             faculty_id=$(cat ${TMP}_FACULTY_DEL)   159.             #### Check If the record of $faculty exists    160.             export n=$(cat $FILE_FACULTY | grep "^${faculty_id}," | wc -l | tr -d " ")   161.             if [ "x$n" == "x0" ] || [ "x$faculty_id" = "x" ] ; then   162.                 msg "Can not find info of $faculty_id !"   163.                 return   164.             fi   165.             ####  Get the info that do not contain the record whose id is $faculty_id    166.             cat $FILE_FACULTY | grep -v "^${faculty_id}," > ${TMP}_FACULTY_DEL   167.             #### Overwrite the file Faculty.dat    168.             mv ${TMP}_FACULTY_DEL $FILE_FACULTY   169.             msg "Delete Info of $faculty_id successfully !"   170.             Studen
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服