Is there a way to add the wireless network which has a wpa/wpa2/certificate + Peap+MsChap+user+password to /etc/network/interfaces?

Am trying to do a bash script that asks user and password and dumps it with addition info such as Peap/Mschapv2/cert into /etc/network/interfaces so it could be automatically activated. Any Ideas?

Am on ubuntu 10.04 - using the GUI network-manager it connects without any problem after adding the user/pass/cert/mschapv2/peap. But I wanted to be configured thru command line?