Sample Header Ad - 728x90

airport -s -x returns truncated output

2 votes
2 answers
298 views
I am the author of wifi-wand, a Ruby command line utility that can be used as a simple way to manage the Mac's WiFi (https://github.com/keithrbennett/wifiwand) without having to learn all the different underlying Mac OS commands and their options. To get a list of network names, I used to use airport -s but found that it does not work because since the network names are right justified (left padded), there is no way to know if leading spaces are part of the name or just there for formatting. So I use airport -s -x to get the information displayed in (pseudo-)XML. This almost always works, but I've noticed in several locations, if there is an HP printer network, the output terminates somewhere in that element. For example: SSID_STR DIRECT-0E-HP OfficeJet 4650 WPS_PROB_RESP_IE IE_KEY_WPS_AP_SETUP_LOCKED IE_KEY_WPS_CFG_METHODS 0 IE_KEY_WPS_DEV_NAME DIRECT-0E-HP OfficeJet 4650 IE_KEY_WPS_DEV_NAME_DATA RElSRUNULTBFLUhQIE9mZmljZUpldCA0NjUw IE_KEY_WPS_MANUFACTURER HP IE_KEY_WPS_MODEL_NAME OfficeJet 4650 series Without the -x option, the output works, but, as I say, there is the space issue that prevents me from relying on it: SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group) NETGEAR25-5G a0:04:60:1a:5a:89 -67 153,-1 Y -- WPA2(PSK/AES/AES) DIRECT-0E-HP OfficeJet 4650 ac:e2:d3:a9:d9:0f -90 6 Y -- WPA2(PSK/AES/AES) iPhone b2:8d:6c:9f:dd:00 -49 1 Y US WPA2(PSK/AES/AES) NETGEAR25 a0:04:60:1a:5a:87 -62 9 Y -- WPA2(PSK/AES/AES) CBCI-4F58 60:3d:26:57:4f:5c -86 6 Y -- WPA2(PSK/AES/AES) What's going on and how can I fix this? Thanks in advance. (The Github issue is at https://github.com/keithrbennett/wifiwand/issues/20.) This HP related error is confirmed at https://clburlison.com/macos-wifi-scanning/ , which says: When you run airport with the --xml flag the command would fail to output properly formatted xml data...one idea is that HP printers are broadcasting a SSID with unsafe characters... [which is close, but it is the model name, not the SSID, that seems to generate the error]
Asked by Keith Bennett (1263 rep)
Nov 2, 2018, 06:23 PM
Last activity: Dec 13, 2023, 06:15 AM