ink-os/get-sudo-password

24 lines
366 B
Bash
Executable File

#!/bin/bash
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