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 want to be able to run some kind of shell script/curl commands to toggle my TV services by accessing a form on my router page using curl or wget.

I have been able to get past authentication using the -u username:password on the command line; Got to the critical page using

/index.cgi?page=services&sessionid=X6dRAsbOxWh9sc9llfGngL9lH4rQOsA>

(I have tried it without the sessionid parameter and the -u and it works)

I have got far enough to be able to set HTML controls, but somewhere a save button calls a piece of JavaScript. I know that the name of the option button is "services" and the value can be 0 or 1, but I dont know how to call the FormSubmit('butt2') in order to submit the values. I can initialize a cookie jar … I seem to be so close but executing the script with the the values set and the right parameter 'butt2'

Please help

Desperate Dad

share|improve this question
    
You'll need to somehow recreate what the Javascript snippet is doing, which probably isn't all that hard -- likely it's just doing form validation. If you'll find that snippet (defined either in the source of the page you're trying to submit, or in a Javascript file included via <script> tag from there, as function FormSubmit(...)), and edit the entirety of that function into your question, that should be enough to let me give you a worthwhile answer. –  Aaron Miller May 8 '13 at 22:18
add comment

1 Answer

What you need to do is not load the page, fill in the form and submit it - but instead just submit the same data directly to the same place that submitting the form manually would normally do.

If you look at the JS on that page, at some point it will do a form.submit, or an ajax submit to a URL. What you need to do is to directly POST the same data, to the same URL as the form would, but using CURL/WGET instead.

Here are some answers that explain how to do that and how to find out what data you need to submit:

share|improve this answer
add comment

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.