example :输入用户名和密码,正确后输入命令
bogon:~ centos$ cat a.sh #!/bin/sh while : do read -p "please input your name: " name read -p "please input your password: " pwd if [ -z $name ] || [ -z $pwd ] then continue fi if [ $name = "alex" -a $pwd = "alex123" ] then echo "login successful" while : do read -p "please input your cmd: " cmd if [ "$cmd" = "quit" ] then break fi $cmd done else echo "login error" fi done echo "--------"