Grabbing a protected webpage from the command line

Ever needed to grab a password protected page from the command line? This can be accomplished with curl’s “-u” option:

$ curl -k -i -u me:somethingstrong |more

The username and password can be passed as an argument to the “-u” option. If you are paranoid about your password being visible on the command line, you can omit the password, and curl will prompt you for it:

$ curl -k -i -u me

In case you are curious, the “-k” option forces curl to dump the HTTP headers. I use both options to debug web server issues.

This article was posted by Matty on 2005-02-19 23:36:00 -0400 -0400