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 am on a network with a firewall that requires a username / password. I want to write a script to do some automated yum installs (specifically, tools to mount an nfs) but first I need to go to a web page in lynx and login to get past firewall. Is there any way I can pass a user / pwd argument to lynx from terminal so it logs in automatically?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I don't know of a way via lynx, but there's a few things you could attempt with curl or elinks, depending on the configuration of the login page.

If it's just basic proxy authentication, you can try passing the username and password via curl:

 curl -u username:password http://example.com

You can also use curl to do more complicated logins, storing session cookies and such. Check out "Using cURL to automate HTTP jobs"

Finally, you may be able to do this in a dirty way using ELinks. ELinks has a function to save a username and password, and also a command line switch to automatically submit a form. By combining the two, this may be what you need:

Enable password saving in elinks.conf by adding this line:

set document.browse.forms.auto_submit = 1

Then run the command to automatically submit the first form on a webpage:

elinks http://example.com/login -auto-submit 1

The problem then is quitting elinks, you may have to kill it in your script.

Good luck.

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.