邮件帐号管理的shell script

这个shell script是用来操作我的邮服帐号的,现在提供了查看,删除,修改,更新等基本功能。还没有最终完成,比如在部分出错处理时,采用简单忽略的处理方式,数据库的备份和恢复也没加进去呢,删除帐号时也没有提供是否要删除邮件内容的的选择,现在是不删,测试嘛,省的删了又建,麻烦,嘻嘻!有时间再来改吧!

真要酬谢我的兄弟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 ""
;;
black_yellow)
echo ""
;;
black_white)
echo ""
;;
black_cyan)
echo ""
;;
red_yellow)
echo ""
;;
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 <

分享到