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

10.3: Display Specific System Profiler information UNIX
for the longest time, I wanted to write a simple script that could quickly find the SSID of the current wireless network that I was operating on. If you're not up on the current technical lingo, a SSID is a Service Set IDentifier, and it's basically the textual name for the wireless access point. I wanted this for a variety of reasons, but mostly I wanted to write/develop a script that would watch for when the SSID changed, and when it changed to tmobile, log on to tmobile so I wouldn't have to do that myself.

However, the only place that I knew this data was avalible from the command line was in the system_profiler tool; the problem was that this tool collected massive amounts of data and could take (on my PowerBook G4) over 1.5 minutes to run -- this was simply not acceptable. After installing Panther, I found that there were a plethora of options now available to limit the amount of data gathered by the system profiler tool. For example, running this command:

system_profiler SPAirPortDataType|grep -e "Current Wireless Network:"|awk '{print $4}'
printed out the current SSID (tmobile at the moment; I'm sitting in a Starbucks in Manhattan), and it takes less than one second to find that information from the system. An amazing speed improvement. If the above fails to find the command, you might have to add /usr/sbin/ in front of it (though that directory should be on your path).

I have not written that script that auto-logs into t-mobile, but will sometime in the future. If you have interest in it or wish to help me (testing, developing) post a message following this hint.
    •    
  • Currently 2.29 / 5
  You rated: 1 / 5 (7 votes cast)
 
[12,358 views]  

10.3: Display Specific System Profiler information | 8 comments | Create New Account
Click here to return to the '10.3: Display Specific System Profiler information' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Display Specific System Profiler information
Authored by: mpetit on Oct 27, '03 04:22:46AM

This does not work properly if you have spaces in the SSID.



[ Reply to This | # ]
10.3: Display Specific System Profiler information
Authored by: steffi on Oct 27, '03 07:02:11AM

Correct

You could try something like this

system_profiler SPAirPortDataType | grep -e "Current Wireless Network:" | sed 's/.*: //'



[ Reply to This | # ]
10.3: Display Specific System Profiler information
Authored by: ajoakland on Oct 27, '03 05:08:25PM
Okay, here we go again:

system_profiler SPAirPortDataType|awk -F": " '/Current Wireless Network/{print $2}'
It eliminates the grep. the -F specifies the field seperator which is a colon followed by a space. The space is added so the space after the colon does not become part of the second field. This splits the line with a colon-space that we care about into two fields, regardless of the other spaces.

The /Current Wireless network/ searches for the line match, just like the grep.

Always looking for a way to do it in less commands. ;)

[ Reply to This | # ]

10.3: Display Specific System Profiler information
Authored by: jsnell on Feb 02, '04 01:17:22PM
I've posted an AppleScript to set iChat status based on SSID at Macworld. Thanks to the people in this thread for saving me from going to Internet Connect to discover the SSID.

---
Jason Snell, Editor, Macworld

[ Reply to This | # ]

10.3: Display Specific System Profiler information
Authored by: ajoakland on Oct 27, '03 09:50:42AM
Howdy, slightly modify the awk line

system_profiler SPAirPortDataType|grep -e "Current Wireless Network:"|awk -F: '{print $2}'
I am still trying out the right syntax to elimite the grep command and make awk do the pattern match. ;) AJ

[ Reply to This | # ]
10.3: Display Specific System Profiler information
Authored by: brettcar on Oct 27, '03 04:42:17PM
I'm the developer of MACMonitor which does something like this only with a GUI. Is there interest in having a similar command-line application to output this in a proper format (and quickly?) If there is, I'd be glad to write it! Send me an e-mail at kenor@users.sf.net if this sounds useful.

[ Reply to This | # ]
10.3: Display Specific System Profiler information
Authored by: babbage on Oct 27, '03 06:40:04PM

If you're looking for info on command line access to your Airport card, there was a package available at http://homepage.mac.com/macstumbler/ that let you play around with Airport from the command line. That site is no longer online, but the file provided has been mirrored all over, for example at http://distfiles.master.finkmirrors.net/airport.tar.gz.

I haven't had a chance to run it on a machine with an airport card yet, so I'm not sure what it can do, but you get full source code (in fact, you have to compile it yourself) so it may be possible to get it to sniff the SSID info.

Alternatively, searching Google for things like "airport wireless command line" etc brings up lots and lots of hits.

---
--
DO NOT LEAVE IT IS NOT REAL


[ Reply to This | # ]

10.3: Display Specific System Profiler information
Authored by: geordie on Oct 27, '03 08:10:21PM

The ability to get specific information out of System Profiler will come in handy for me (decoding the serial number from ioreg is a pain), but for finding out the Airport network name (SSID) I use 'osascript -e 'tell application "Internet Connect" to get network name of AirPort configurations''.



[ Reply to This | # ]