mtr/traceroute to a url
I often want to traceroute (or better: mtr) to a host for debugging or curiosity purposes.
I also noticed that while Safari doesn't show you the http:// or https:// prefix, it does add the prefix when copy pasting.
So I often find myself trying to mtr http://coderwall.com/p/new which doesn't work.
If you add the following function to your .zshrc (or adapt it to match your shell-of-choice), it uses Ruby to extract the hostname and feeds that mtr.
function mtr {
host=`ruby -ruri -e "puts (URI.parse('$1').host or '$1')"`
echo host: $host
/usr/local/sbin/mtr -t $host
}
Written by Frank Louwers
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#