Replace variables as needed
then you can just dhclient the interface to get an addressCode:ifconfig $WLANINT up iwconfig $WLANINT essid $ESSID key $KEY iwconfig $WLANINT #check if you're connected
p.s. if the key is in ascii form, you have to use s:$KEY



) so text mode helps me there)