Skip to main content

I whipped this up today and thought I would share.

I threw it into Automator in a "Run Shell Script" action and saved it out as
an application. Then I replaced the default *.icns file with something a
little more appropriate and pushed it out to /Applications/Utilities/ as "My
IP Address.app". At the request of the Service Desk guys I shoved it into
the end of everyone's Dock via Casper as well.

When we get more Mac Pros next year I will fix it up to account for the
second ethernet interface etc. but for now I am only dealing with iMacs and
MacBooks.

#!/bin/bash

# This simply displays an AppleScript dialog showing the IP addresses of the
default Ethernet and Airport interfaces for Macs with only one of each.

# Ryan Manly - ryan.manly at gmail.com - 021910

en0=ipconfig getifaddr en0 2>&1

en1=ipconfig getifaddr en1 2>&1

if [ "$en0" = "get if addr en0 failed, (os/kern) failure" ]; then

en0="unavailable"

fi

if [ "$en1" = "get if addr en1 failed, (os/kern) failure" ]; then

en1="unavailable"

fi

/usr/bin/osascript << EOF

tell application "Finder"

activate

display dialog "Wired IP Address: $en0" & return & "Wireless IP Address:
$en1" buttons {"OK"} with icon caution

end tell

EOF

exit 0

If anyone has critiques for making it cleaner, faster, better. Please
respond! :) I am sure there is better way to check for the failure…

Cheers,

Ryan M. Manly
Level 4 Mac Tech
Glenbrook High Schools
1835 Landwehr Rd.
Glenview, IL 60026
(847) 486-4948

? ACSP ? ACMT

Why not just use MCX to display the IP at the login window?