Created
March 10, 2011 11:32
-
-
Save imom0/863973 to your computer and use it in GitHub Desktop.
A shell script to get the 150 IPs of xjtu lib.
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 | |
lock=/tmp/mac_lock | |
wlan=wlan0 | |
essid=xjtu_lib | |
mac_base="C9:1A:B9:6B:6C:" | |
function req_addr() { | |
if [ -f "$lock" ] | |
then | |
echo "Please remove the lock $lock first." | |
else | |
sudo touch $lock | |
sudo ifconfig $wlan down | |
sudo ifconfig $wlan hw ether $mac_base$mac_count | |
sudo ifconfig $wlan up | |
echo "Interface $wlan is working." | |
sudo iwconfig $wlan mode managed | |
sudo iwconfig $wlan essid "$essid" | |
sudo dhcpcd $wlan | |
echo "Got an IP address." | |
sudo dhcpcd -x $wlan | |
sudo rm $lock | |
fi | |
} | |
for count in `seq 0 255` | |
do | |
mac_count=$(printf "%.2X\n" $count) | |
req_addr | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment