Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ########################################################################
- #
- # location-cascade
- # $Id: location-cascade,v 1.7 2018/07/05 09:11:51 elias Exp $
- #
- # Give a list of HTTP redirections for a given URI.
- # Requires lynx.
- #
- ########################################################################
- # Useragent "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)'
- # Paranoia line
- PATH=/bin:/usr/bin
- # Temporary file name
- tmpfile=`tempfile -p locas` || exit 1
- if [ -z "$1" ]
- then
- echo "Usage: `basename $0` <URI>" 1>&2
- exit 1
- fi
- trap "rm -f $tmpfile" 1 2 15
- echo $1 >$tmpfile
- while [ -s $tmpfile ]
- do
- uri=`cat $tmpfile`
- lynx -useragent="$UA" -mime_header "$uri" 2>/dev/null |
- sed '/^\s*$/q' |
- grep -i '^Location:' |
- sed -e 's/^[^:]*:\s*//' -e 's/\s$//' |
- tee $tmpfile
- done | nl -
- rm -f $tmpfile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement