Shell脚本编写登陆小程序.sh

转至:https://www.cnblogs.com/gaohongyu/articles/12072594.html

复制代码
#!/bin/bash
#Author:GaoHongYu
#QQ:1061767621
#Time:2019-12-19 02:47:09
#Name:login.sh
#Version:V1.0

FILE_PATH=/root/user_list

read -p "Please enter user name:" user
grep -w $user $FILE_PATH &> /dev/null
if  [ $? -eq 0 ];then
     echo -n "Please enter passwd:"
     read -s passwd
     password=$(grep -A 1 $user $FILE_PATH|tail -1)
     if [ $passwd == $password ];then
             echo
             echo "Land successfull"
     else
             echo
             echo "Wrong password"
         fi
 else
     echo "${user} user not exist "
     read -p "Whether to create users,To create a user enter y,To exit press q:" choose
     if [ $choose == 'y' ];then
          read -p "Please enter user name:" new_user
          grep -w $new_user $FILE_PATH &> /dev/null
          if [ $? -eq 0 ];then
             echo "$new_user already existed"
     else
         echo "$new_user" >> $FILE_PATH
         read -p "Please $new_user enter passwd:" new_passwd
         echo "$new_passwd" >> $FILE_PATH
         echo "User $new_user creating successful"
         fi
     elif [ choose == 'q' ];then
         echo "exit program"
         exit
     fi
 fi
复制代码

测试:

 

 

作者: 高宏宇

出处:https://www.cnblogs.com/gaohongyu/articles/12072594.html

版权:本文采用「署名-非商业性使用-相同方式共享 4.0 国际」知识共享许可协议进行许可。

posted @   study_goup  阅读(335)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示