Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Simple user-interaction based login script
  4.  
  5. username="root"
  6. password="toor"
  7.  
  8. #set -x #tracing code line on
  9.  
  10. echo "You have 10 sec to type"
  11. echo -n "username > "
  12. if read -t 10 response; then
  13. if [ $response = $username ]; then
  14. echo "hello $username"
  15. echo -n "password > "
  16. else
  17. echo "user not found"
  18. exit
  19. fi
  20.  
  21. if read -s -t 10 response; then
  22. if [ $response = $password ]; then
  23. echo "login success"
  24. # This line is where the actual magic starts
  25. echo "logging out."
  26. else
  27. echo "wrong password"
  28. fi
  29. else
  30. echo "Sorry! too slow"
  31. echo "You should type credendials in 10 sec"
  32. fi
  33. else
  34. echo "Sorry! Too slow!"
  35. echo "Session timed out"
  36. fi
  37.  
  38. #set +x #tracing code line off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement