Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to connect to a wifi network where it hijacks all requests and redirects you to a page where you have to agree to a terms of use before it lets you connect to the actual outside world. This is a pretty common practice, and usually doesn't pose much of a problem.

However, I've got a computer running Ubuntu 9.10 server with no windowing system. How can I use the command line to agree to the terms of use? I don't have internet access on the computer to download packages via apt-get or anything like that. Sure, I can think of any number of workarounds, but I suspect there's an easy way to use wget or curl or something.

Basically, I need a command line solution for sending an HTTP POST request essentially clicking on a button. For future reference, it'd be helpful to know how to send a POST request with, say, a username and password if I ever find myself in that situation in another hotel or airport.

share|improve this question
1  
see this answer about using curl for a similar command-line-webpage-button-pusher technique. i'd post it here but it'd just be a cut-n-paste job; no point in that. if you come up with exact steps to take, post as your own answer. –  quack quixote Apr 20 '10 at 4:42

2 Answers 2

up vote 3 down vote accepted

Install Lynx in advance, and then use Lynx from the command line. Lynx is a text based browser.

Alternatively, you can try using wget or curl to get www.google.com and then analyse the HTTP file returned.

share|improve this answer
1  
links will do a better job than lynx -- it's a slightly more modern browser. (no really. use links. check your local package manager.) –  quack quixote Apr 20 '10 at 4:38
    
+1 links works just great. Really easy to use and does the job just fine. –  Saif Bechan Apr 20 '10 at 5:29
    
I ended up using this answer this time (downloaded lynx with a separate computer and transferred the file over usb), but it's probably time I actually learn how to use curl. –  Shane Apr 20 '10 at 16:30

You will have to look once at the source of the login form to find out the names of the user and password fields. As the authentication redirect all pages, use any URL to get that source:

curl http://www.google.com > login.html

For example, you'll find:

<form method="POST" action="http://my-public-provider.com/agree.php">
    <input type="checkbox" name="agree" value="yes">I agree
    <input type="submit" name="push" value="Send">
</form>

Another way is to use (on an other computer) a proxy such as Fiddler2 to see what is sent "over the wire" by the browser.

Then you can build your curl command to post your form information:

curl -d "agree=yes&push=Send" http://my-public-provider.com/agree.php

If you do not have curl, it is possible to write a simple HTTP client with a language you may have on the platform (Perl, Lua, Java...).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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