Advertisement
imcrazytwkr

Tumblr list checker (stage-1)

Dec 6th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. print() {
  4.   printf '%s' "$1"
  5. }
  6.  
  7. println() {
  8.   printf '%s\n' "$1"
  9. }
  10.  
  11. if [ -z "$(which curl)" ]; then
  12.   println 'Curl was not found on your system.'
  13.   println 'Please install it or add the directory it resides in to your PATH.'
  14.   exit 2
  15. fi
  16.  
  17. if [ -d "$2" ]; then
  18.   println 'You have supplied an existing directory as a destination file.'
  19.   println 'Please supply a proper filename or filepath.'
  20.   exit 1
  21. fi
  22.  
  23. if [ -f "$2" ]; then
  24.   rm $2
  25. fi
  26.  
  27. println 'url,status,redirects_to' > $2
  28.  
  29. printf 'Started cheacking tumblr blogs from list file %s.\n' $1
  30. println 'Progress will be displayed in dots.'
  31.  
  32. while read -r url; do
  33.   printf '%s,' $url >> $2
  34.   curl -I -L -s -o /dev/null -w '%{http_code},%{url_effective}\n' $url >> $2
  35.   print '.'
  36. done < $1
  37.  
  38. println
  39. println '[DONE]'
  40.  
  41. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement