diff options
author | epochqwert <epoch@hacking.allowed.org> | 2015-04-21 13:41:40 -0500 |
---|---|---|
committer | epochqwert <epoch@hacking.allowed.org> | 2015-04-21 13:41:40 -0500 |
commit | 318b3220d191011bb9132efd4dbd5e6fb467b4e7 (patch) | |
tree | 1b0e7a29d15f79743c8559652432658423046a38 /nocompile/bin/ipdist.sh | |
parent | 4bdfc44f4681ef322378e614a409d5acc4d6586c (diff) | |
download | misc-318b3220d191011bb9132efd4dbd5e6fb467b4e7.tar.gz misc-318b3220d191011bb9132efd4dbd5e6fb467b4e7.zip |
made dcchelper a script instead of a c program.
ipdist which gives shortest distance based on whob's output of lat and lon
nc.* are minmal versions of a netcat like program written in Perl.
rfc is a script for downloading and viewing RFCs
tpb.sh is for pulling magnet links from tpb search results.
cuturl got an upgrade to better handle scheme:?query_string type URLs. (URN? URI? fuck if I know.)
Diffstat (limited to 'nocompile/bin/ipdist.sh')
-rwxr-xr-x | nocompile/bin/ipdist.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nocompile/bin/ipdist.sh b/nocompile/bin/ipdist.sh new file mode 100755 index 0000000..ca97696 --- /dev/null +++ b/nocompile/bin/ipdist.sh @@ -0,0 +1,26 @@ +#!/bin/sh +if [ "_$1" = "_" -o "_$2" = "_" ];then + echo "usage: $0 hostA hostB" + exit +fi + +#constants for now. +c=299.792458 #km/ms of light in vacuum +iof=1.4475 #picked the higher of two from wikipedia. +# http://en.wikipedia.org/wiki/Optical_fiber#Index_of_refraction + +ipA=$(gethostbyname "$1") +ipB=$(gethostbyname "$2") +A=$(whob "$ipA" | egrep "^Lat|^Lon" | cut '-d ' -f2 | tr '\n' ' ') +B=$(whob "$ipB" | egrep "^Lat|^Lon" | cut '-d ' -f2 | tr '\n' ' ') +km=$(echo "$A" "$B" \ + | geod +ellps=clrk66 -I +units=km \ + | cut -f3) +ms=$(printf '%s / %s * %s\n' "$km" "$c" "$iof" | bc) + +echo "ipA: $ipA" +echo "ipB: $ipB" +echo "c: $c" +echo "iof: $iof" +echo "km: $km" +echo "ms: $ms" |