在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 #!/bin/bash 2 #Author:GaoHongYu 3 #QQ:1061767621 4 #Time:2019-12-19 02:47:09 5 #Name:login.sh 6 #Version:V1.0 7 8 FILE_PATH=/root/user_list 9 10 read -p "Please enter user name:" user 11 grep -w $user $FILE_PATH &> /dev/null 12 if [ $? -eq 0 ];then 13 echo -n "Please enter passwd:" 14 read -s passwd 15 password=$(grep -A 1 $user $FILE_PATH|tail -1) 16 if [ $passwd == $password ];then 17 echo 18 echo "Land successfull" 19 else 20 echo 21 echo "Wrong password" 22 fi 23 else 24 echo "${user} user not exist " 25 read -p "Whether to create users,To create a user enter y,To exit press q:" choose 26 if [ $choose == 'y' ];then 27 read -p "Please enter user name:" new_user 28 grep -w $new_user $FILE_PATH &> /dev/null 29 if [ $? -eq 0 ];then 30 echo "$new_user already existed" 31 else 32 echo "$new_user" >> $FILE_PATH 33 read -p "Please $new_user enter passwd:" new_passwd 34 echo "$new_passwd" >> $FILE_PATH 35 echo "User $new_user creating successful" 36 fi 37 elif [ choose == 'q' ];then 38 echo "exit program" 39 exit 40 fi 41 fi 测试: |
请发表评论