Locking a terminal
Richard Steinberger
ric at ace.sri.com
Fri Sep 7 01:40:31 AEST 1990
Someone posted a C program to lock a TTY. Here is a shell script that
does the same thing.
I got much of this from a popular Unix book, Sobell's Practical Guide
to the Unix System. (Don't leave home without it. The 2nd edition
has this script on p 261, but fails to trap ^Z!).
Note that the trap and stty commands are used to lock out ^C and ^Z.
regards,
ric steinberger
------------------------------cut here--------------------------------
#!/bin/sh
# Lock a TTY
trap '' 1 2 3 15
stty -echo susp ''
echo -n "Password: "
read pw_1
echo
echo -n "Again: "
read pw_2
echo
pw_3= #set to null string
if [ "$pw_1" = "$pw_2" ]
then
until [ "$pw_3" = "$pw_2" ]
do
echo -n "Lock Password: "
read pw_3
echo
done
else
echo "Lock passwords do not match."
fi
stty echo susp '^Z'
More information about the Comp.lang.c
mailing list