Guest User

Untitled

a guest
Apr 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/bin/sh
  2. # Script for automatic mapping wireless network interface to available and known
  3. # access point. For more details see interfaces(5) mapping options. Example
  4. # interfaces(5) file is provided.
  5. #
  6. # Note that access point ESSID and first argument in ``map'' directive should
  7. # match.
  8.  
  9. IFACE="$1"
  10. CTRL_SOCKET="/var/run/wpa_supplicant"
  11.  
  12. # We cannot perform AP scanning until interface is down. Bring up wlan interface
  13. # with wpa_supplicant and wait a little.
  14. wpa_supplicant -i $IFACE -C $CTRL_SOCKET &
  15. PID=$!
  16. sleep 5
  17.  
  18. SCAN_RESULT=`mktemp`
  19. iwlist $IFACE scan > $SCAN_RESULT
  20.  
  21. # Simple check of scanning results. Script stops searching when first AP is
  22. # found.
  23. while read SSID IFACE_ALIAS ; do
  24. if ( grep "ESSID:\"$SSID\"" $SCAN_RESULT > /dev/null ) ; then
  25. echo $IFACE_ALIAS
  26. break
  27. fi
  28. done
  29.  
  30. # Come cleanup before exit.
  31. kill $PID
  32. rm $SCAN_RESULT
  33.  
  34. exit 0
Add Comment
Please, Sign In to add comment