Created
November 28, 2016 19:40
-
-
Save andermoran/1ae3230a37dcdfd1685b7883248acab3 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
# Prompts user for password until the password is correct | |
# Useful for programs where you must get the correct password from the user in order to execute a command | |
passOk="false" | |
while [ "$passOk" != "true" ] | |
do | |
echo -n "Password: " | |
read password # Grabs username | |
if [[ $(echo $password | sudo -k -S echo valid) = "valid" ]] &>/dev/null; then | |
echo "Correct password" | |
passOk=true | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment