# .bash_profile
# Get the aliases and functions //取得别名和函数
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs //用户的详细环境变量和启动项目
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME /////////////////////////////////////
printf "\n\tThis is a exam machine!\n"
printf "\tPress \"exam\" to exam system! Press \"Enter\" to normal system! "
read item
#printf "\n"
l if [[ "$item" == exam ]]
then
l if [[ -f /var/exam/.05Net0708_1/.05Net.list || -f /var/exam/.06Net0708_1/.06Net.list ]]
-f 文件存在,且为普通文件
then
list=0506Net
else
list=none
l fi
l if [[ $PS1=="[\u@\h \W]\\$" && $list!=none ]]
then
printf "\tEnter your student's number: "
read studentnum
set $(echo ${#studentnum})
length=$1
while(( $length !=9 ))
do
printf "\n\tYour ID error!"
printf "\n\tEnter your student's number again: "
read studentnum
set $(echo ${#studentnum})
length=$1
done
//这部分是针对05级的考试系统
l if grep "$studentnum" /var/exam/.05Net0708_1/.05Net.list >& /dev/null //查看是在考试学生文档是否有存在
then
grep "$studentnum" /var/exam/.05Net0708_1/.05Net.list|cut -d " " -f1 > temp
set $(cat temp)
Englishname=$1
rm -rf temp
elif grep "$studentnum" /var/exam/.06Net0708_1/.06Net.list >& /dev/null
//查看是在考试学生文档中是否有存在考生信息
then
grep "$studentnum" /var/exam/.06Net0708_1/.06Net.list|cut -d " " -f1 >& temp
set $(cat temp)
//$1是英文姓名,$2是考生号
Englishname=$1
rm -rf temp
else
printf "\n\tYour ID no exist!"
printf "\n\tYou must login again! "
sleep 2
logout
l fi//这部分是针对05级的考试系统
printf "\n\tWelcome $Englishname to exam!"
printf " Hostname is $Englishname now!"
printf "\n\tHave a fun to use it!\n"
printf "\n"
PS1="[\u@$Englishname \W]\\$"
rm -rf /root/05*
rm -rf /root/06*
rm -rf /root/07*
l if [ -d /root/$studentnum ] -d 是否存在且为目录
then
rm -rf /root/$studentnum
mkdir /root/$studentnum
cd /root/$studentnum
else
mkdir /root/$studentnum
cd /root/$studentnum
l fi
l if [[ -d /var/exam/student ]]
then
rm -rf /var/exam/student
l fi
/var/exam/.exam_init //启动另外的考试系统文件
l if [[ $? == 3 ]] 返回值
then
exit 3
l fi
hostname $Englishname
OLDPATH=$PATH
PATH=/root/$studentnum:$OLDPATH
export PS1 PATH USERNAME ENV
l fi
else
export PATH USERNAME ENV
fi
//以上应用原来的环境变量
//以下zhcon
printf "\n\tThis machine has been installed software Zhcon!\n"
printf "\tZhcon--a fast CJK console enviroment for Linux!\n"
printf "\tWould you like to use it?\n\n"
printf "\tPress \"zhcon\" to run zhcon! Press anykey to normal system! "
read answer
printf "\n"
if [[ $answer != zhcon || -z $answer ]]
then
true
else
zhcon
fi