Created
September 4, 2013 02:12
-
-
Save gabrielkfr/6432038 to your computer and use it in GitHub Desktop.
Script demostrativo que detalla la programación necesaria para ocultar con asteriscos la contraseña cuando se la introduce durante la ejecución de un script bash.
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
#!/bin/bash | |
# | |
# SCRIPT DE PRUEBA - LEER CONTRASENIAS | |
# ==================================== | |
# | |
# -- Se libera la variable. | |
unset SECRET_PASSWD | |
# -- Se solicita la introduccion del password y | |
# se despliega un asterisco por cada character | |
# introducido por el usuario. | |
echo | |
PROMPT="Introduzca su password: " | |
while IFS= read -p "$PROMPT" -r -s -n 1 char; do | |
if [[ $char == $'\0' ]]; then | |
break | |
fi | |
PROMPT='*' | |
SECRET_PASSWD+="$char" | |
done | |
echo | |
# -- Despliegue del password: | |
echo | |
echo "El password introducido fue: $SECRET_PASSWD" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment