10

This uses a shell script to list your public facing IP addresses, as well as en0 (ethernet) and en1 (AirPort). For AirPort, if the system is connected to a network, it will also list the SSID.

The following script is embedded in the glet file that you can download below.

#!/usr/bin/perl 

$en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`; 
$en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`; 
$ext_info = `curl --silent http://checkip.dyndns.org | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'`;
$airport_network = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F: '/ SSID: / {print $2}' | sed -e 's/.*SSID: //'`; 
if($ext_info) { 
    $output .= "External: $ext_info"; 
} else {
    $output .= "External: OFFLINE \n";
} 
if($en0_info) { 
    $en0_info =~ /inet (.*) netmask/s; 
    $output .= "Ethernet: $1 \n"; 
} else {
    $output .= "Ethernet: INACTIVE \n";
} 
if($en1_info) { 
    $en1_info =~ /inet (.*) netmask/s; 
    $en1_info = $1; 
    $output .= "Airport: $en1_info \n";
    $output .= "SSID: $airport_network"; 
} else { 
    $output .= "Airport: INACTIVE";
} 
print "$output";

Geeklet files to download

Comments

User Avatar
jkcolo22 706 days ago
Is this working for anyone? I did chmod +x then ran and get:

Joes-MBP:~ jkcolo22$ /Users/jkcolo22/scripts/IP-status.glet

/Users/jkcolo22/scripts/IP-status.glet: line 1: syntax error near unexpected token `newline'

/Users/jkcolo22/scripts/IP-status.glet: line 1: `'
User Avatar
duder 380 days ago
Hi there, the line starting with ext_info seems to be broken — not only in this script but also in other geeklets. probably changed its output form. My script-fu is pretty weak (or rather non-existing). After fiddling for some time I just hope someone can fix the cut and tr commands. Right now cut seems to filter the *whole* output...
User Avatar
matt 380 days ago
I've had a go at fixing it. Seems to be working fine now for me. I've also embedded the script within the .glet file, so you can just download that and double-click it instead of having to worry about copying and pasting.
User Avatar
duder 379 days ago
Thanks a lot, it works flawlessly now.

Log in to comment or register here.