1

My internet connection is provided by the university. It is protected to a username/password combination. This means when I start up my computer, I have to start a web browser and open an arbitrary website. I am then redirected to a page, which (among other things) contains two forms. In these I have to input username and password. I managed to do this with firefox (which can save the password) and also with links (which loads faster and from the command line).

Is there any way to automate the login process using a bash script? This would allow doing the login when booting,because there is no web browser in raspberry

  • I understand you want to automate the process, but just for the sake of completeness: there is a web browser on the RPi, called Midori, and if you want to stay on the command line, you can use lynx. – LuWi Apr 20 '14 at 14:57
  • I need to automate the process. when rapspberry boot, I want that it automatically login to be able to access internet that others process need to run. – Makhlouf GHARBI Apr 21 '14 at 13:09
3

When you login to a webpage, what is (usually) happening behind the scenes is an HTML POST request to a URL. So to replicate that from the command line you need to know:

  1. The URL the POST request is going to
  2. The POST parameters that are being sent (usually a user name and a password)

cURL is a command line tool for interacting with sites via HTML. You can make a POST request by sending data using the --data option along with a string containing parameter names and values in the format curl --data "parameter1=value1&parameter2=value2" http://some-url.com/some-login-page

From your comment, it looks like the fields you need are called login and passwd so the cURL request would look like:

curl --data "login=your-username&passwd=your-password" http://the-url.com

  • it doesn't really work. for username and password, you mean that in the code below I should make:.......... curl --data "user=value1&passwd=value2" hostname/resource. ?? <input name='login' id='user' type="text"> <input name='passwd' id='passwd' type='password'> – Makhlouf GHARBI Apr 21 '14 at 12:16
  • This is the error after entering the command as suggested by you.. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 405 Method Not Allowed</title> </head> <body><h2>HTTP ERROR 405</h2> <p>Problem accessing /console/login. Reason: <pre> Method Not Allowed</pre></p><br/> <br/> </body> </html> – Prashanthhh Kumarr Feb 19 '17 at 21:03
  • You'll need to try the login in Chrome and check what is happening using the Network tab in the inspect window. Then you can reproduce it with curl – Jamie Bull Feb 19 '17 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.