Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. # Write shell script to implement terminal locking (similar to lock command). It should prompt the user for password. After accepting the password entered by the user, it must prompt again for matching password as confirmation and if match occurs, it must the lock the keyboard until a matching password is entered again by the user, Note that the script must be written to disregard BREAK, control-D. No time limit need be implemented for the lock duration.in
  2.  
  3. #!/bin/sh
  4. clear
  5. f=1
  6. echo -e "Enter password: \c"
  7. read -s password1
  8. echo -e "\nRe-enter password: \c"
  9. read -s password2
  10.  
  11. if [ $password1 == $password2 ]; then
  12.     echo -e "\n\nMatch found"
  13. else
  14.     while [ 1 ]
  15.     do
  16.         if [ $f -eq 3 ]; then
  17.             echo -e "\n\nWrong password"
  18.             exit
  19.         else                       
  20.             echo -e "\n\nEnter password: \c"
  21.             read -s password1
  22.             echo -e "\nRe-enter password: \c"
  23.             read -s password2
  24.             if [ $password1 == $password2 ]; then
  25.                 echo -e "\n\nMatch found"
  26.                 exit
  27.             fi
  28.             f=`expr $f + 1`
  29.         fi
  30.     done
  31. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement