Created
April 18, 2016 16:10
-
-
Save akpoff/0a1bd5bab81d78a0863747ba55f0065b to your computer and use it in GitHub Desktop.
Get the nwid of the specified wlan card or the first found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
nic="$1" | |
function getNwid { | |
ifconfig $1 | grep ieee80211 | cut -d : -f 2 | rev | cut -d ' ' -f 5- | rev | cut -d ' ' -f 3- | tr -d '"' | |
} | |
if [ ${nic:-empty} = empty ] | |
then | |
wnics_up=$(ifconfig wlan | grep UP | cut -d ':' -f 1) | |
if [ ${wnics_up:-empty} = empty ] | |
then | |
wnics=$(ifconfig wlan | cut -d ':' -f 1) | |
for wnic in $wnics | |
do | |
echo $wnic: Not connected | |
exit | |
done | |
else | |
for wnic in $wnics_up | |
do | |
nwid=$(getNwid $wnic) | |
echo $wnic: $nwid | |
exit | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment