NiKaro127

Retreive script from Pastebin

Feb 28th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Usage :
  4. #
  5. # Just retreive file from pastebin :
  6. # 'pastebin.sh arg1 arg2'
  7. # arg1 : pastebin file ID
  8. # arg2 : destination file
  9. # example : 'pastebin.sh nL9DDqeT /usr/local/bin/pastebin.sh'
  10. #
  11. # Retreive script and set executable :
  12. # 'pastebin.sh arg1 arg2 arg3'
  13. # arg1 : '-x' to set executable
  14. # arg2 : pastebin file ID
  15. # arg3 : destination file
  16. # example : 'pastebin.sh -x nL9DDqeT /usr/local/bin/pastebin.sh'
  17.  
  18. # Check if set file to be executable is wanted
  19. if [ $1 == "-x" ]; then
  20.     # Delete first argument ('-x')
  21.     shift 1
  22.     # Store in a variable chmod command to execute later
  23.     cmd="chmod +x $2"
  24. fi
  25.  
  26. # Retreive script
  27. wget -qO- "http://pastebin.com/raw.php?i=$1" | tr -d '\r' > $2
  28.  
  29. # If previously set, execute chmod command
  30. $cmd
Advertisement
Add Comment
Please, Sign In to add comment