注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 小五思科技术学习笔记之SSH
 帮助

期末Linux课程设计(1)—.bash_profile部分


2007-12-28 16:39:36
 标签:Linux 系统 考试    [推送到技术圈]

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://roytiger.blog.51cto.com/298409/57159
# .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
 
 

本文出自 “┉の秂吥行別說路吥平﹖.!.” 博客,请务必保留此出处http://roytiger.blog.51cto.com/298409/57159





    文章评论
 
2007-12-28 16:42:27
来看看啦。

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: