I have an odd request and there's a long explanation, but instead of going into the story I'll ask for help.

I have a jailbroken iPhone 4 (5.1.1) with MobileTerminal installed and I would like to know how to connect to a wifi network using terminal commands and please note any additional commands that need to be installed through cydia if necessary.