#首页:登录,注册
read -p "
---------->考试系统<-------------
登录--------------1
注册--------------2
退出--------------3
" a;
#登录界面:
A () {
echo "
------------>欢迎<--------------
";
read -p " 用户名:" name;
if [ -z $name ] ;then
read -p "用户名不能为空!";
clear ;
A;
else
nm=`cat /root/shell/han/1.txt | grep $name | cut -d " " -f 1`;
name=$nm;
if [ -z $name ] ;then
echo " 用户不存在!"
echo "";
/root/shell/han/first.sh ;
else
echo;
echo;
read -s -p " 密码:" passwd;
pw=`cat /root/shell/han/1.txt | grep $name | cut -d " " -f 2`;
if [ $passwd == $pw ] ;then
echo " 登录成功!";
/root/shell/han/a.sh ;
else
read -p " 密码错误!";
clear ;
A;
fi
fi
fi
}
#注册页面:用户名、密码
B () {
echo "
----------注册----------
"
echo ;
read -p "请输入用户名:" name;
if [ -z $name ] ;then
read -p "用户名不能为空!";
clear ;
B;
else
nm=`cat /root/shell/han/1.txt | grep $name | cut -d " " -f 1`;
if [ -z $nm ] ;then
read -s -p "请输入密码:" passwd;
echo "$name $passwd" >>1.txt
read -p "注册成功!请登录";
/root/shell/han/first.sh ;
else
read -p "用户已存在!";
clear ;
B;
fi
fi
}
#判断:
if [ $a == 1 ] ;then
clear ;
A;
elif [ $a == 2 ] ;then
clear ;
B;
elif [ $a == 3 ] ;then
read -p "已退出!";
clear ;
else
echo "请选择正确选项!"
./first.sh;
fi
#副页
#考试系统:
clear ;
read -p "
-------------->高一(三)班<----------------
<-----------课程选择------------->
语文-------------------1
数学-------------------2
英语-------------------3
物理-------------------4
化学-------------------5
生物-------------------6
退学+.+--------7
" a;
A () {
i=1;
j=6;
z=0;
read -p " `cat /root/shell/han/$q/$i` " a1;
while [ $i -le 5 ] ;do
read -p " `cat /root/shell/han/$q/$i` " a1;
if [ $a1 = "`cat /root/shell/han/$q/$j`" ] ;then
echo "回答正确!";
z=0;
z=$(expr $z + 1);
i=$(expr $i + 1);
j=$(expr $j + 1);
echo $z
else
echo "回答错误!";
i=$(expr $i + 1);
j=$(expr $j + 1);
fi
done
echo $z
}
case "$a" in
1) #语文
clear ;
if [ $a = 1 ] ;then
q=1;
A;
/root/shell/han/a.sh ;
fi
;;
2)#数学b:
clear ;
if [ $a = 2 ] ;then
q=2;
A;
/root/shell/han/a.sh ;
fi
;;
3)#英语:
clear ;
if [ $a = 3 ] ;then
q=3;
A;
/root/shell/han/a.sh ;
fi
;;
4)#物理:
clear ;
if [ $a = 4 ] ;then
q=4;
A;
/root/shell/han/a.sh ;
fi
;;
5)#化学:
clear ;
if [ $a = 5 ] ;then
q=5;
A;
/root/shell/han/a.sh ;
fi
;;
6)#生物:
clear ;
if [ $a = 6 ] ;then
q=6;
A;
/root/shell/han/a.sh ;
fi
;;
7)#退学;
clear ;
echo "把你家长叫来!我要谈话!";
/root/shell/han/first.sh ;
;;
*)
clear ;
echo "请联系班主任!"
/root/shell/han/first.sh ;
;;
esac