Skip to content

Instantly share code, notes, and snippets.

@gabrielkfr
Created September 4, 2013 02:09
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 gabrielkfr/6432026 to your computer and use it in GitHub Desktop.
Save gabrielkfr/6432026 to your computer and use it in GitHub Desktop.
Script demostrativo que detalla la programación necesaria para ocultar la contraseña cuando se la introduce durante la ejecución de un script bash.
#!/bin/bash
#
# SCRIPT DE PRUEBA - LEER CONTRASENIAS
# ====================================
#
# -- Se guarda la configuracion de la sesion
# stty actual.
STTY_SAVE=`stty -g`
stty -echo
 
# -- Se solicita la introduccion del password al
# usuario:
echo
echo -n "Introduzca su password: "
read SECRET_PASSWD
 
# -- Se restablece la sesion stty anterior.
stty $STTY_SAVE
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