Actually, I would suggest sending a dbus message to the network control software, which would take care of all of that for you. However, the dbus ontology is very meagerly documented, and to discover the magic incantation you'll have to execute "dbus-monitor" with the correct command line arguments. Then (with the interface shut off) start the web browser showing an outside URL. It will send the signal, and when the net comes up a dbus signal returns to the browser and it knows it can download and show that page. And you will have trapped the dbus chatter that makes it happen, so you can imitate in your command line application.