Created
June 27, 2017 21:12
-
-
Save cagcak/cdf543065b1e28121a2e9feff4d97be4 to your computer and use it in GitHub Desktop.
Simple user-interaction based bash login script
This file contains 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 | |
# Simple user-interaction based login script | |
username="root" | |
password="toor" | |
#set -x #tracing code line on | |
echo "You have 10 sec to type" | |
echo -n "username > " | |
if read -t 10 response; then | |
if [ $response = $username ]; then | |
echo "hello $username" | |
echo -n "password > " | |
else | |
echo "user not found" | |
exit | |
fi | |
if read -s -t 10 response; then | |
if [ $response = $password ]; then | |
echo "login success" | |
# This line is where the actual magic starts | |
echo "logging out." | |
else | |
echo "wrong password" | |
fi | |
else | |
echo "Sorry! too slow" | |
echo "You should type credendials in 10 sec" | |
fi | |
else | |
echo "Sorry! Too slow!" | |
echo "Session timed out" | |
fi | |
#set +x #tracing code line off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment