You are not logged in.
Pages: 1
Hello,
I need to get AP MAC out of this iwconfig output:
lo no wireless extensions.
eth0 no wireless extensions.
wifi0 no wireless extensions.
ath0 IEEE 802.11g ESSID:"linksys" Nickname:""
Mode:Managed Frequency:2.462 GHz Access Point: 00:11:22:33:44:55
Bit Rate:48 Mb/s Tx-Power:18 dBm Sensitivity=1/1
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=31/70 Signal level=-63 dBm Noise level=-94 dBm
Rx invalid nwid:3152 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
I've done it like this but this regexp I've come up with seems silly:
iwconfig ath0 2>&1 | grep -E -o '[0123456789ABCDEF]{2}:[0123456789ABCDEF]{2}:[0123456789ABCDEF]{2}:[0123456789ABCDEF]{2}:[0123456789ABCDEF]{2}:[0123456789ABCDEF]{2}'
Can you please suggest a more clean way to do it?
P.S. Notice that iwconfig outputs to stderr by default.
.
Last edited by karabaja4 (2010-01-21 18:56:17)
Offline
cat /sys/class/net/ath0/address
Offline
cat /sys/class/net/ath0/address
Please read more carefully, I need access point MAC address (BSSID), not my card MAC
Offline
iwconfig 2>&1|sed -n "s/.*Access Point: \(\([0-9A-F]\{2\}:\)\{5\}[0-9A-F]\).*/\1/;T;p"
This works, and only extracts six colon separated double uppercase hexadecimal digits occuring after the string "Access Point: ", however, it can surely be made shorter since the output from iwconfig is not "free" but follows a pattern.
edit:
Case in point:
iwconfig 2>&1| grep "Access Point"|cut -d\ -f18
Last edited by tlvb (2010-01-21 19:56:46)
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
iwconfig wlan0 | grep -o 'Ac.*' | sed 's,.*: ,,'
Offline
iwconfig ath0 | awk '/Ac/ {print $6}'
So many ways
Last edited by Bralkein (2010-01-21 22:39:05)
Offline
Okay, thanks all
Now, maybe there is some way to get the value direcly?
Something like already mentioned command
cat /sys/class/net/ath0/address
but for AP MAC adress?
Offline
iwconfig ath0 |egrep -o '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'
Offline
Pages: 1