Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Script for automatic mapping wireless network interface to available and known
- # access point. For more details see interfaces(5) mapping options. Example
- # interfaces(5) file is provided.
- #
- # Note that access point ESSID and first argument in ``map'' directive should
- # match.
- IFACE="$1"
- CTRL_SOCKET="/var/run/wpa_supplicant"
- # We cannot perform AP scanning until interface is down. Bring up wlan interface
- # with wpa_supplicant and wait a little.
- wpa_supplicant -i $IFACE -C $CTRL_SOCKET &
- PID=$!
- sleep 5
- SCAN_RESULT=`mktemp`
- iwlist $IFACE scan > $SCAN_RESULT
- # Simple check of scanning results. Script stops searching when first AP is
- # found.
- while read SSID IFACE_ALIAS ; do
- if ( grep "ESSID:\"$SSID\"" $SCAN_RESULT > /dev/null ) ; then
- echo $IFACE_ALIAS
- break
- fi
- done
- # Come cleanup before exit.
- kill $PID
- rm $SCAN_RESULT
- exit 0
Add Comment
Please, Sign In to add comment