期末Linux課程設計(1)—.bash_profile部分

# .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

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章