Skip to content

Instantly share code, notes, and snippets.

@Shivakishore14
Created July 1, 2019 22:04
Show Gist options
  • Save Shivakishore14/bdac680be4de027cae0a171f007fcef8 to your computer and use it in GitHub Desktop.
Save Shivakishore14/bdac680be4de027cae0a171f007fcef8 to your computer and use it in GitHub Desktop.
sudo_fun_hack_script
function sudo_() {
args="$@"
echo $args
flag=0
sudo touch /usr/bin/samplesec.txt &> /dev/null
if [ "$?" -eq 0 ]; then
flag=1
sudo $args
fi
while [ $flag -eq 0 ]; do
echo "Enter password :"
read pass
echo $pass | sudo -S touch /usr/bin/samplesec.txt &> /dev/null
if [ "$?" -eq 0 ]; then
sudo $args
break
fi
echo "Sorry, try again"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment