真要酬谢我的兄弟p4s2wd啊,前些日子,他发了个在线音乐的网址给我,让我听某个电台,我的firefox无法正常显示,我生气就换成win2000了,我的shell稿子,就这么一生气忘了备份了,呵呵呵,装完系统,补丁更新完毕,重启,啊,win2000起不来了,我晕倒!算了,还是换回来吧!于是又用debian sarge做桌面!这时候才想起来,我的那个脚本没有备份!还好我运气虽然差,还没差到家,呵呵,我记得给我兄弟p4s2wd发过一次,请他斧正的,于是让他又发回给我!他没删噢!哈哈
#!/bin/sh
#menu
#Main Menu Script
#set -x
#ignore CTRL-C and QUIT interrupts
trap "" 2 3 15
MYDATE=`date +%d/%m/%Y`
THIS_HOST=`hostname -s`
USER=`whoami`
#User level file
USER_LEVELS=priv.user
#hold file
HOLD1=hold1.$$
#select1_result file
SELECT1_RESULT=select1_result.$$
#seleclt_op file
SELECT1_OP=select1_op.$$
#Colour function
colour()
{
#format is background;foregroundm
case $1 in
black_green)
echo "[40;32m"
;;
black_yellow)
echo "[40;33m"
;;
black_white)
echo "[40;37m"
;;
black_cyan)
echo "[40;36m"
;;
red_yellow)
echo "[41;33m"
;;
esac
}
#Just read a single key please
#get_char()
#{
#get_char
#Save current stty settings
#SAVEDSTTY=`stty -g`
#stty cbreak
#dd if=/dev/tty bs=1 count=1 2> /dev/null
#stty -cbreak
#stty $SAVEDSTTY
#}
#Turn the cursor on or off
cursor()
{
#cursor
#turn cursor on/off
_OPT=$1
case $_OPT in
on) echo "[?25h"
;;
off) echo "[?25l"
;;
*) return 1
;;
esac
}
#check what privilege level the user has
restrict()
{
colour red_yellow
echo -e -n " 07Sorry you are not authorised to use this function"
colour black_green
}
user_level()
{
#user_level
#read in the priv.user file
while read LINE
do
case $LINE in
#ignore comments
#*)
;;
*)
echo $LINE >> $HOLD1
;;
esac
done < $USER_LEVELS
FOUND=false
while read MENU_USER PRIV
do
if [ "$MENU_USER" = "$USER" ]
then
FOUND=true
case $PRIV in
yes|YES)
return 0
;;
no|NO)
return 1
;;
esac
else
#no match found read next record
continue
fi
done <$HOLD1
if [ "$FOUND" = "false" ]
then
echo "Soryy $User you have not been authorised to use this menu"
exit 1
fi
}
#called when user selects quit
my_exit()
{
#my_exit
#called when user selects quit!
colour black_white
cursor on
rm *.$$
exit 0
}
tput init
#display their user levels on the screen
if user_level; then
ACCESS="Access Mode is High"
else
ACCESS="Access Mode is Normal"
fi
my_select1()
{
clear
colour black_green
cat <