-2

IP Information

Posted in System by Khelmar 3617 days ago

This uses a shell script to list the IP addresses of en0 (ethernet) and en1 (AirPort). For AirPort, if the system is connected to a network, it will list the SSID and channel connected.

The needed shell script (thanks to Appi for the suggestion about the PrivateFramework!) is here - the lines that start with myvar1 and myvar2 should each be on one line one below the next:

#! /bin/bash

myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "$myen0" != "" ]
then
    echo "Ethernet : IP - $myen0"
else
    echo "Ethernet : INACTIVE"
fi

myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "$myen1" != "" ]
then
    myvar1=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep -e "SSID:" | tail -n 1 | awk '{print $2}'`
    myvar2=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep -e "channel:" | awk '{print $2}'`
    echo "AirPort   : IP - $myen1
               Network - $myvar1
               Channel - $myvar2"
else
    echo "Airport   : INACTIVE"
fi

Geeklet files to download

Comments

Log in to comment or register here.