Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ########################################################################
- #
- # location-cascade
- # $Id: location-cascade,v 1.1 2017/01/14 17:22:21 elias Exp $
- #
- # Give a list of HTTP redirections for a given URI.
- # Requires lynx.
- #
- ########################################################################
- # User-agent
- # internet exploiter 10 for best results from spammy sites ;)
- UA='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)'
- httpcode=0
- uri=$1
- lasturi="$uri"
- while test "$httpcode" -lt 400 -o ! -z "$uri"
- do
- set `lynx -useragent="$UA" -mime_header "$uri" 2>&1 |
- sed -e '/^\s*$/q' |
- awk '/^HTTP/ { code = $2 }
- /^Location/ { uri = $2; gsub("\\r", "", uri) }
- END { print code, uri }'`
- lasturi="$uri"
- httpcode="$1"
- uri="$2"
- echo "$httpcode\t$lasturi"
- test "$httpcode" -eq 200 && break
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement