免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 850 | 回复: 0
打印 上一主题 下一主题

期末Linux课程设计(1)—.bash_profile部分 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-23 11:27 |只看该作者 |倒序浏览
               
                # .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


               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93926/showart_1874744.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP