Oct 24, '05 04:23:00AM • Contributed by: RedEyedEnglisher
This script pings an external site once, and returns the routing information which is then chopped up by sed and awk to return the bare public IP address of the router, interspaced with periods. This version works in tcsh:
ping -c 1 -R www.yahoo.com | awk -F: \
'{ if ($1 == "RR") print $2 }' | \
awk -F ( '{ print $2 }' | sed 's/)//'
And here's a version that works in bash:
ping -c 1 -R www.yahoo.com | awk -F: \
'{ if ($1 == "RR") print $2 }' | \
awk -F "(" '{ print $2 }' | sed 's/)//'
[robg adds: This worked as described...]
