Created
February 3, 2012 14:05
-
-
Save theist/1730322 to your computer and use it in GitHub Desktop.
redirect test script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = ARGV.shift | |
redirect = true | |
while redirect do | |
redirect = false | |
status = "" | |
location = "<none>" | |
curl = `curl -s -I #{url}|dos2unix` | |
curl.each_line do |line| | |
if line =~ /HTTP\/1..\s+(\d+)/ then | |
status = $1 | |
end | |
if line =~ /^Location:\s*(.*)/ then | |
location = $1 | |
end | |
end | |
puts "#{url} -> #{status} -> #{location}" | |
if status =~ /3../ then | |
redirect = true | |
url = location | |
end | |
end |
Author
theist
commented
Feb 6, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment