Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- u=0
- p=0
- e=0
- for arg in "$@"
- do
- if [ "$arg" == "-u" ] && [ "$u" == 0 ]
- then
- u=1
- continue
- fi
- if [ "$u" == 1 ]
- then
- if [[ "$arg" =~ ^[A-Za-z0-9]{1,}$ ]]
- then
- user=$arg
- else
- echo "Username is not valid!"
- exit 1
- fi
- u=2
- fi
- if [ "$arg" == "-p" ] && [ "$p" == 0 ]
- then
- p=1
- continue
- fi
- if [ "$p" == 1 ]
- then
- if [ ${#arg} -lt 3 ]
- then
- echo "Password is to short!"
- exit 1
- fi
- if [[ "$arg" =~ [A-Z] ]]
- then
- ok=1
- else
- echo "Password $arg is insecure!"
- exit 1
- fi
- if [[ "$arg" =~ ^[A-Za-z0-9._%+-]{1,}$ ]]
- then
- pass=$arg
- fi
- p=2
- fi
- if [ "$arg" == "-e" ] && [ "$e" == 0 ]
- then
- e=1
- continue
- fi
- if [ "$e" == 1 ]
- then
- if [[ "$arg" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]
- then
- email=$arg
- else
- echo "Email is not valid!"
- exit 1
- fi
- e=2
- fi
- done
- if [ "$p" == 0 ]
- then
- echo "User $user has email $email"
- else
- echo "User $user has the email $email and password $pass"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement