I would like to use the following command line to get the current Wi-Fi channel.

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

I would like to use exactly this command, because it's possible that I'm using more parts of the result. So I'm needing an AppleScript that returns me only the current Wi-Fi channel of the command.

I'm thankful for any help. :)

2 Answers 2


Here is an example In AppleScript using tron_jones's answer.

The result of the command is set to _channel and then used in a dialog box just to show the result. Obviously _channel can be used in a variety of ways.

set _channel to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep 'channel:' | awk '{print $2}'"
display dialog "Wi-Fi is using Channel: " & _channel

Note: The fully qualified pathname for grep and or awk may need to be supplied. Also the double-quotes around grep "channel:" were replaced with single-quotes so the command could be incapsulated in double-quotes in order to compile due to the single-quotes in the awk command.

By the way, the command can be reduced to the following using asterisks (*) to shorten the written path to the airport command:

set _channel to do shell script "/S*/L*/P*/A*/V*/C*/R*/airport -I | grep 'channel:' | awk '{print $2}'"

To shorten the command line further, thanks to bmike, in a Terminal use the following command to create the symlink:

sudo ln -s "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" "/usr/local/bin/airport"

Then, as an example in Terminal, all you need to do is type: airport -I

Or in an AppleScript command using the previous example:

set _channel to do shell script "airport -I | grep 'channel:' | awk '{print $2}'"
  • For what is the $2?
    – user121028
    Jul 1, 2015 at 14:34
  • It is the second field of the input record to awk. .../airport -I | grep "channel:" outputs channel: 11 and pipes it to awk and it prints "11" as it's $2. If you said awk '{print $1}' the result would have been "channel:". Jul 1, 2015 at 14:40
  • Thank you for your extensively reply. It works and was/is very helpful. :)
    – user121028
    Jul 1, 2015 at 14:49
  • Maybe you can help me in this also: How can I create from the full result a list in AppleScript? With as list I'm getting an error. I think the problem is that there are no commas before a return.
    – user121028
    Jul 1, 2015 at 14:52
  • 1
    @user121028 One question per question - also asking a new one in comments is considered very poor form. It makes one look a little bit like a "help vampire" although you're not showing any signs of that malady other than asking it in comments.
    – bmike
    Jul 1, 2015 at 14:54

I would recommend using the "grep" and "awk" commands from bash. You can use them to parse the data given in bash. Here is example using the details you described above.

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep "channel" | awk '{print $2}'

Do yourself a favor and sym link the binary to /usr/local/bin so you can just type airport (or script it)

airport -I | grep "channel" | awk '{print $2}'
  • Where can I change to /user/local/bin? With a new Terminal window it doesn't work.
    – user121028
    Jul 1, 2015 at 14:55
  • @user121028, In a Terminal, use the following command to create the symlink: sudo ln -s "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" "/usr/local/bin/airport" Then, as an example, all you need to do is type: airport -I Jul 1, 2015 at 15:00
  • Why would you use grep and awk? airport -I | awk '/channel/{print $2}' Sep 15, 2015 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .