Skip to content

Instantly share code, notes, and snippets.

@aaronmehar
Created September 20, 2016 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronmehar/40e9626b6195248804ec11b81d7f64d4 to your computer and use it in GitHub Desktop.
Save aaronmehar/40e9626b6195248804ec11b81d7f64d4 to your computer and use it in GitHub Desktop.
#!/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}"
@aaronmehar
Copy link
Author

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^%

@aaronmehar
Copy link
Author

aaronmehar commented Sep 20, 2016

$ 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