#!/bin/bash wid=0 extip=`lynx -dump "http://checkip.dyndns.org" | grep -o --extended-regexp "([0-9]{1,3}\.){3}[0-9]{1,3}"` if (( "${#extip}" > $wid )); then # echo "check 1 $wid" wid=${#extip} fi exthost=`host $extip | grep -o --extended-regexp "[^ ]*$" | grep -o --extended-regexp ".*[^\.]"` if (( "${#exthost}" > $wid )); then # echo "check 2 $wid" wid=${#exthost} fi intip=`sudo ifconfig | grep -o --extended-regexp "inet addr.([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -o --extended-regexp "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v --extended-regexp "127\.([0-9]{1,3}\.){2}[0-9]{1,3}"` if (( "${#intip}" > $wid )); then # echo "check 3 $wid" wid=${#intip} fi #echo $wid wid=$(( $wid + 17 )) echo -n "wid is: " echo $wid line="" count=0 while (( $count < $wid )); do line="$line" count=$(($count+1)) done line="$line" echo $line if (( $(( $wid&1 )) == 0 )); then #check if number is even side=$(( $(($wid - 8)) / 2)) text="IP INFO" else side=$(( $(($wid - 7)) /2)) text="IP INFO" fi count=0 line="" while (( $count < $side )); do line="$line" count=$(($count+1)) done echo -n "" echo -n $line echo -n $text echo -n $line echo "" line="" count=0 while (( $count < $wid )); do line="$line" count=$(($count+1)) done line="$line" echo $line temp=$(($wid - ${#extip} - 16)) count=0 line="" while (( $count < $temp )); do line="$line" count=$(($count+1)) done line="$line" echo -n " External IP: " echo -n $extip echo $line echo -n "" temp=$(($wid - ${#exthost} - 16)) count=0 line="" while (( $count < $temp )); do line="$line" count=$(($count+1)) done line="$line" echo -n " External Host: " echo -n $exthost echo $line line="" count=0 while (( $count < $wid )); do line="$line" count=$(($count+1)) done line="$line" echo $line temp=$(($wid - ${#intip} - 16)) count=0 line="" while (( $count < $temp )); do line="$line" count=$(($count+1)) done line="$line" echo -n " Internal IP: " echo -n $intip echo $line line="" count=0 while (( $count < $wid )); do line="$line" count=$(($count+1)) done line="$line" echo $line