Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

View IP address info with GeekTool Apps
I have created a little script that I use with GeekTool to show me my IP Address, what media is connected (WiFi/Ethernet), and my IP Address as the world sees me. The script is a culmination of some other hints and uses a program called setproxy, which I found on this website (original hint, setproxy's page).

I have it polled by Geektool every now and then, and I keep the script in an executable file in /usr/local/bin. I hope it helps someone out there. I'm not sure why, but the formatting doesn't seem to work in the Terminal window, but it's fine with Geektool.

See the script

Just copy and paste the above text into your favorite Terminal text editor, save it somewhere on your path, and make it executable (chmod 755 script_name). Then set up GeekTool to run the script (see GeekTool's Pick of the Week page for more info on the app).

[robg adds: I haven't tested this one.]
    •    
  • Currently 3.00 / 5
  You rated: 2 / 5 (5 votes cast)
 
[24,413 views]  

View IP address info with GeekTool | 12 comments | Create New Account
Click here to return to the 'View IP address info with GeekTool' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
IPMenu
Authored by: Fofer on Oct 06, '04 12:31:16PM

I use the freeware IPMenu:
http://www.loopware.com/software/
Puts a nice menulet that tells me my external and internal IP with a click.



[ Reply to This | # ]
IPMenu
Authored by: jimcintosh on Oct 06, '04 03:15:30PM

I like IPMenu and use it. The only problem I've found is that the external IP it reports will be that of the http proxy if you have one. I've written the author to suggest using the real IP number rather than that of the proxy, and he said he would consider it for a future release.



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: LegoEvan on Oct 06, '04 01:38:49PM

I have this echoed in the lower left hand corner of my screen:<br>
<br>
Get IP.sh<br>
[code]
#!/bin/sh

ifconfig | grep 'broadcast' | awk '{print $2}'
[/code]<br>
I find it waaay simpler.



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: Whosawhatsis on Oct 07, '04 02:52:03AM

I got you beat.

ifconfig | awk '/broadcast/ {print $2}'

---
I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: Chealion on Oct 06, '04 01:48:29PM

Personally I just use this;

[code]ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'};
curl -s www.whatismyip.com | grep 'Your IP is' | awk {'print $4'}
[/code]

All internal IPs (excluding loopback addresses), and your external (on internet) IP according to whatismyip.com.

---
Chealion - The one and only! =)



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: steveo52 on Oct 06, '04 05:39:06PM

There's a widget for this if you use Konfabulator, works awesome.

http://www.widgetgallery.com/view.php?widget=36005



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: jemuel85 on Nov 04, '08 09:44:31PM

I tried using your script, but the external IP does not seem to be working...



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: nicksay on Oct 06, '04 08:37:36PM
I've written yet another version of this script. This one is longer that the other replies, but gives you the Media for each IP like the original does. It also lists all the internal IP addresses, not just the primary one. It even right-aligns the IP addresses in the display. It's written entirely in bash (meaning, no awk).

ipinfo.sh
#!/bin/bash
function pad {
	string="$1"; num="$2"; count=$(echo -n "$string" | wc -c); ((count += 0))
	while (( count < num )); do string=" $string"; ((count += 1)); done
	echo -n "$string"
}
idx=0; mode="media"; info=$(ifconfig | fgrep -B 2 netmask)
for i in $info; do
	case "$mode" in
		media)
			case "$i" in
				en0*)	media[$idx]="Ethernet"; mode="ip";;
				en1*)	media[$idx]="WiFi"; mode="ip";;
				en*)	media[$idx]=""; mode="ip";;
			esac;;
		ip)
			if [[ "$i" == [0-9]*.[0-9]*.[0-9]*.[0-9]* ]]; then
				ip[$idx]="$i"; ((idx += 1)); mode="media"
			fi;;
	esac
done
for ((i=0; i < ${#media[*]}; i++)); do
	if [[ $ip ]]; then
		ip=$(pad ${ip[$i]:-Unknown} 15)
		echo "Internal  $ip    (via ${media[$i]})"
	fi
done
ip=$(curl -s www.whatismyip.com | fgrep 'Your IP is' | awk {'print $4'})
ip=$(pad ${ip:-Unknown} 15)
echo "External  $ip"
Just copy and paste into a new file, save as whatever you like and follow the original instructions.

[ Reply to This | # ]
View IP address info with GeekTool
Authored by: Anonymous on Mar 13, '05 08:51:09PM

Something's changed on the website that will now make your external IP number display as "is". However, I believe that changing

ip=$(curl -s www.whatismyip.com | fgrep 'Your IP is' | awk {'print $4'})

to

ip=$(curl -s www.whatismyip.com | fgrep '<title>Your ip is' | awk {'print $4'})

fixes it.



[ Reply to This | # ]
View IP address info with GeekTool
Authored by: l007mp on Oct 18, '04 11:48:55PM
View IP address info with GeekTool
Authored by: bi66er on Mar 14, '05 09:20:56AM
whatismyip.com, with GeekTool, has already been tried above by Chealion

[ Reply to This | # ]
View IP address info with GeekTool
Authored by: jemuel85 on Nov 05, '08 12:11:47AM
After trying for an hour, i realized that www.whatismyip.com has an auto page that allows the script to read the IP without a grep.

Here's my code

[code]
ifconfig | grep netmask | grep -v 127.0.0.1 | awk {'print $2'};
curl -s www.whatismyip.com/automation/n09230945.asp | awk {'print $1'}
[/code]

This simply just displays both internal and external IP addresses in 2 lines. You can modify it to display text.

[ Reply to This | # ]