Something along these lines...
Code:
sudo wpa_passphrase <router name> > config_file
<enter password at stdin prompt>
sudo wpa_supplicant -iwlan0 -cconfig_file -B
sudo dhclient