#!/bin/bash # A small utility to easily connect to the wireless networks that I # use frequently. # Version 0.1.1. # Originally written 23-July-2006. # Last modified 24-July-2006. # Michael V. De Palatis # You may redistribute this under the terms of the GNU GPL v. 2. # Which device is your wirless card? DEVICE="eth1" # Connect to the passed network. function connect { if [[ $2 == "" ]]; then sudo iwconfig $DEVICE essid $1 sudo dhclient $DEVICE else sudo iwconfig $DEVICE essid $1 key $2 sudo dhclient $DEVICE fi } # Network and WEP key arrays. # Add your networks here. declare -a NETWORKS declare -a KEYS NETWORKS[0]="utexas" KEYS[0]="" NETWORKS[1]="canus" KEYS[1]=yourkeygoeshere # If no parameters were passed, display the networks. if [[ ${#*} = 0 ]]; then echo "What wireless network do you want?" echo "Available networks are: ${NETWORKS[*]}" exit fi # Connect to the specified network. i=0 while [[ $i < ${#NETWORKS[@]} ]]; do if [[ ${NETWORKS[$i]} = $1 ]]; then connect ${NETWORKS[$i]} ${KEYS[$i]} exit fi ((i++)) done echo "Invalid network."