I want to connect to Internet using wireless automatically(using a script or program)

Currently,I do the following steps to connect to Internet by wlan:

  1. Select the wlan access point,
  2. Then KDE desktop will prompt a authentication windows to input my root password
  3. Then open my browser. A webpage from the access point server is shown. The page is for me to input the username and password I have bought
  4. Then I submit the form waiting for response
  5. Last, connected.

I am wondering if I can have all those steps performed in a program or a script.

For step 3 and 4, I think I can use curl to POST data.

But prior to this step, how can I do the the following:

  1. select wlan access point in KDE Network Manager(any command or library?).
  2. input the password KDE prompted for me.

2 Answers 2


NetworkManager provides a command line interface in the application nmcli.

This can be used to inspect and initiate/terminate connection, but as I understand it cannot be used to configure new connections.


The way these "captive portal" WLANs work, two things are to be discerned:

  1. local network connection, which enables you to access the captive portal (web form) but nothing further
  2. connecting to the internet, unlocked using the captive portal

where (1) works as always and (2) needs something to be done, i.e., entering a password in some web form. As you already noticed, (2) can be solved using curl. So what's missing is having NetworkManager auto-connect - to get (1). See here for NetworkManager's ability to auto-connect on boot without a user logged in or some wallet unlocked, where this bug report about knetworkmanagers missing ability to configure the auto-connect thing is mentioned which has since been marked "resolved", so you might want to try finding some preference in knetworkmanagers options.

Another possibility I found useful is that in some situations, the (1) step combined with a VPN connection does the trick, too. So if this is the case, you can save yourself the hassle of curling the web form. (Which could probably also be done using the dispatcher, see the last link.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .