콘솔에서 무선접속하기

[code:xkjj89gn]#!/bin/bash
#console_net.sh
DEFAULT_IF=iwconfig 2>/dev/null|head -1|awk '{print $1}'
IF=${1:-$DEFAULT_IF}
iwconfig 2>/dev/null|awk ‘{print $1}’|grep $IF 2>/dev/null >/dev/null && shift||IF=$DEFAULT_IF
ESSID=iwlist $IF scanning|grep ESSID|sed 's/.*ESSID://g'|head -1
ESSID="${1:-$ESSID}"
#sudo service networking start
sudo ifconfig $IF down
sudo ifconfig $IF up
sudo iwconfig $IF essid "$ESSID" key off
sudo iw dev $IF connect "$ESSID"
if which dh_client >/dev/null 2>/dev/null; then
sudo dh_client $IF
else
sudo dhclient $IF
fi
iwconfig[/code:xkjj89gn]

사용법
console_net.sh 무선장치명 접속위치
예) console_net.sh wlan0 iptime_1