I would like to be able to get the speed of the wireless interface under Mac OS X. I have a perl script that gets the other information for the wireless card but I still need to get the connection speed.
For the moment I have statically set the airport speed with: $airport_rate = "54"; (see code below).
What command could I use to get the speed of the built in airport card or what am I missing in my code below. Thanks
EDIT: This code now works. Thanks. Sample output for the script:
ETHERNET IP : 192.168.2.7 AIRPORT IP : 192.168.2.4 AIRPORT STATUS : CONNECTED SSID : Forcefield RATE : 54 Mb/s
#!/usr/bin/perl
# a little script to get your network status
$en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`;
$en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`;
$airport_info = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I`;
if($en0_info)
{
$en0_info =~ /inet (.*) netmask/s;
$output .= "ETHERNET IP : $1\n";
}
else
{ $output .= "ETHERNET IP : INACTIVE\n"; }
if($en1_info)
{
$en1_info =~ /inet (.*) netmask/s;
$en1_info = $1;
$airport_info =~ /lastTxRate: (\d\d\d)/s;
$airport_rate = $1;
$airport_info =~ /BSSID(.*?)SSID: (.*?)\n/s;
$airport_SSID = $2;
$output .= "AIRPORT IP : $en1_info\n";
$output .= "AIRPORT STATUS : CONNECTED\n";
$output .= " SSID : $airport_SSID\n";
$output .= " RATE : $airport_rate Mb/s\n";
}
else
{
$output .= "AIRPORT STATUS : INACTIVE\n";
}
print "$output";