首页 > 其他 > 详细

创建用户并发送邮件

时间:2019-03-07 19:33:59      阅读:186      评论:0      收藏:0      [点我收藏+]
echo -n "创建用户输入C,删除用户输入D!"
read name
function monitor() 
{
if [ "$name" == "C" ] || [ "$name" == "c" ];then
    function_create
  elif [ "$name" == "D" ] || [ "$name" == "d" ]; then
    function_rm
  else
    echo "Input Error"
fi
}


function_create ()
{
echo -n "输入用户名(英文全拼):"
read USER_LIST
#echo -n "输入用户邮箱:"
#read MAIL_LIST
echo -n "输入授权ip地址"
read IP_LIST
#DATE=$NAME
USER_FILE=./user.txt
for USER in $USER_LIST; do
    if ! id $USER &>/dev/null; then
        PASS=$(echo $RANDOM |md5sum |cut -c 1-8)
        useradd $USER
        echo $PASS |passwd --stdin $USER &>/dev/null
        echo "$USER   $PASS" >> $USER_FILE
        echo "$USER User create successful."
      echo -n "输入用户邮箱:"
      read MAIL_LIST
      echo $MAIL_LIST
      for MAIL in $MAIL_LIST;do
          if !  $MAIL  &>/dev/null; then 
              echo "USR:$USER PWD:$PASS IP:$IP_LIST" |mail -s "monitor" $MAIL
            else
              echo "邮箱错误"
          fi
      done
    else
        echo "$USER User already exists!"
    fi
done
}

 
#function_rm ()
#{
#echo 222
#}
monitor

 

创建用户并发送邮件

原文:https://www.cnblogs.com/Carr/p/10491493.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!