Advertisement
goebelmasse

Weiterleitungskette (vereinfachte, robustere Version)

Nov 28th, 2017
1,998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.94 KB | None | 0 0
  1. #!/bin/sh
  2. ########################################################################
  3. #
  4. # location-cascade
  5. # $Id: location-cascade,v 1.7 2018/07/05 09:11:51 elias Exp $
  6. #
  7. # Give a list of HTTP redirections for a given URI.
  8. # Requires lynx.
  9. #
  10. ########################################################################
  11.  
  12. # Useragent "Internet Exploiter 10" for best results from spammy sites ;)
  13. UA='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)'
  14.  
  15. # Paranoia line
  16. PATH=/bin:/usr/bin
  17.  
  18. # Temporary file name
  19. tmpfile=`tempfile -p locas` || exit 1
  20.  
  21. if [ -z "$1" ]
  22. then
  23.     echo "Usage: `basename $0` <URI>" 1>&2
  24.     exit 1
  25. fi
  26.  
  27. trap "rm -f $tmpfile" 1 2 15
  28. echo $1 >$tmpfile
  29.  
  30. while [ -s $tmpfile ]
  31. do
  32.     uri=`cat $tmpfile`
  33.     lynx -useragent="$UA" -mime_header "$uri" 2>/dev/null |
  34.     sed '/^\s*$/q' |
  35.     grep -i '^Location:' |
  36.     sed -e 's/^[^:]*:\s*//' -e 's/\s$//' |
  37.     tee $tmpfile
  38. done | nl -
  39.  
  40. rm -f $tmpfile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement