Created
September 20, 2016 11:10
-
-
Save aaronmehar/40e9626b6195248804ec11b81d7f64d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
r="\033[31m" | |
b="\033[1;34m" | |
g="\033[32m" | |
w="\033[0m" | |
bold="\033[1m" | |
underline="\033[4m" | |
print_info() { echo -e "$b[ INFO ]$w $1"; } | |
print_fail() { echo -e "$r[ FAIL ]$w $1"; } | |
print_ok() { echo -e "$b[ OK ]$w $1"; } | |
while getopts "u:p:" flag | |
do | |
case "$flag" in | |
u) USERNAME="${OPTARG}" ;; | |
p) PASSWORD="${OPTARG}" ;; | |
esac | |
done | |
print_info "Authentication Checker" | |
echo="================================================" | |
echo "${USERNAME}" | |
echo "${PASSWORD}" |
$ bash bashtest.sh -u myuser -p #mypass!
bashtest.sh: option requires an argument -- p
[ INFO ] Authentication Checker
[ INFO ] Username is: myuser
[ FAIL ] Please place your password in quotes
$ bash bashtest.sh -u myuser -p "#mypass!"
[ INFO ] Authentication Checker
[ INFO ] Username is: myuser
[ INFO ] Password is: #mypass!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aarons-mbp:Rackspace Cloud aaronmehar$ bash bashtest.sh -u test -p #34^%
bashtest.sh: option requires an argument -- p
[ INFO ] Authentication Checker
test
aarons-mbp:Rackspace Cloud aaronmehar$ bash bashtest.sh -u test -p "#34^%"
[ INFO ] Authentication Checker
test
#34^%