I want to write a script-Ubuntu_OS- would connect to a wireless Internet so I need to know how to connect Internet via terminal in Linux. I tried many suggestions on the Internet but nothing at all
By your question i assume you want a script to connect to a wi-fi network using a linux script and access internet.
Scan all networks available
iwlist wlan0 scan
From the list select essid of wi-fi netwwork you want to connect
if ESSID is "" use access-point
You could try using WICD network manager, it has a CLI network manager you can install.
You could also try using the Ceni script from smxi, which has worked great for me in a few cases where WICD and Gnome-network-manager were not working.
These won't really be a script to start a network connection, but both are accessible from command line and both will let you scan for networks, connect, put in keys, etc. in a nice manner.