shell

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 "--------"

  

 

posted @ 2017-03-24 10:53  golangav  阅读(278)  评论(0编辑  收藏  举报