shell脚本编写简单登陆

环境准备
准备一台Centos6服务器
系统: Centos6.8
内存:1G
cpu: 2核
IP地址: 10.0.0.21
# 创建shell脚本
 vim root.sh 
#!/bin/bash
user=root
password=123
read -ep "用户:" username

if [ $user == $username ];then
   read -ep "密码:" pass
  if [ $pass -eq $password ];then
      echo "登陆成功"
  else
      echo "密码不对,退出脚本"
  fi
else
    echo "用户名不存在"
fi
# 执行脚本
sh root.sh 

在这里插入图片描述

发布了68 篇原创文章 · 获赞 24 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/aaronszm/article/details/103773152
今日推荐