ink-os/get-sudo-password
2021-08-29 14:55:37 +09:30

25 lines
365 B
Bash
Executable File

#!/bin/sh
file=/tmp/sudo-password
while true;
do
read -r -s -p "Your password please: " password
res=$(echo "$password" | sudo -S -k -l)
echo $res
if [ "$res" == "" ]; then
echo "Incorrect password, try again..."
else
break;
fi
done
rm $file --force # to ignore if it isn't there
touch $file
echo "$password" > $file