Sunday 10 August 2014

Write shell script to implement terminal locking (similar to the lock command). It should prompt the user for a password. After accepting the password entered by the user, it must prompt again for the matching password as confirmation and if match occurs, it must lock the keyword 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.


stty –echo
while true
do
clear
echo "Enter the paasword"
read pass1
echo "Re enter the password"
read pass2
if [ $pass1 = $pass2 ]
then
echo "Terminal locked"
echo "To unlock enter the password"
pass1=""
until [ "$pass1" = "$pass2" ]
do
read pass1
done
echo "Terminal unlocked"
stty echo
exit
else
echo "Password mismatch retype it"
fi
done

0 comments:

Post a Comment

 
- |