#!/bin/bash # Copyright (c) 2010 Luis R. Rodriguez # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING O # Pretty colors GREEN="\033[01;32m" YELLOW="\033[01;33m" NORMAL="\033[00m" BLUE="\033[34m" RED="\033[31m" PURPLE="\033[35m" CYAN="\033[36m" if [ $# -ne 1 ]; then echo -e "Usage: $0 " exit fi SSID="$1" # assumes you have a control interface exposed, # If you want to use this with network-manager ensure # you modify your dbus settings for wpa_supplicant. This is # documented here: # # http://wireless.kernel.org/en/users/Documentation/wpa_supplicant#Enabling_control_interface_and_nl80211_driver echo -e "${CYAN}Issuing first scan...${NORMAL}" # XXX: add 'iw event -c 1' support sudo wpa_cli scan echo -e "${CYAN}Waiting for results...${NORMAL}" #sleep 5 echo -e "${CYAN}Collecting scan results...${NORMAL}" ESS=$(sudo wpa_cli scan_results| grep $SSID | awk '{print $1}') COUNT=$(echo $ESS | wc -w) echo -e "${RED}$COUNT ${NORMAL}APs found on ESS ${GREEN}$SSID${NORMAL}, going to roam between them now" echo -e "AP list:${NORMAL}" echo -e "\t${GREEN}BSS\t\t\t${YELLOW}Freq${NORMAL}" for i in $ESS; do FREQ=$(sudo wpa_cli scan_results| grep $i | awk '{print $2}') echo -e "\t${GREEN}$i\t${YELLOW}$FREQ" done while true; do for i in $ESS; do FREQ=$(sudo wpa_cli scan_results| grep $i | awk '{print $2}') echo -e "${NORMAL}Roaming to ${CYAN}${SSID} ${GREEN}${i} ${YELLOW}${FREQ} ${NORMAL}MHz..." sudo wpa_cli roam $i; sleep 5; done; done