script for interacting with a router's admin website
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
script for interacting with a router's admin website
Hi,
We are testing a wireless device on a lot of commonly used wireless routers.
For that purpose it would be efficient if we could somehow automate the process of changing the routers parameters to different settings and save them.
They're not high-end routers so they don't have snmp or terminal functionality.
What possible options could we try ?
Edit: I think one way to do it would be to send the html commands to the router on port 8080 (or 80 for some)
Is that possible ?
Last edited by oneindelijk; 10-12-2012 at 03:26 PM.
you would - at least - say the type of that router. jdownloader has a similar functionality, it is implemented in java, probably you can get some tips from there.
Many different kinds of devices these days have built-in HTTP servers to provide a monitoring and/or configuration tool for end users. In many cases, it is fairly simple to craft an HTTP client that interacts independently with the server (device; router in your case). However, many devices rely on the likes of Javascript, Java applets, and other client-side scripting, and some even rely on browser-specific behavior (came across one the other day that wouldn't work without Internet Explorer).
It should be easy to see whether your device uses these languages. Just use wget or curl to fetch a page or two from the device, and examine the reply. If it is all plain HTML (some CSS is okay), then you're probably good to go. If there is Javascript &/or Java applets uploaded, then you're probably hooped. Once you've established feasibility, you will need to use a combination of your wget/curl tool set, as well as a conventional browser to see what URLs and arguments are used.
Creating a smart HTTP client requires a reasonably complete programming language such as Perl, Python, or C. You will need to be able to parse HTML, and this can be tricky, but there are existing libraries for most languages to help out. Perl is my preferred tool for this task. You will need to divine by inspection and trial and error, what responses the device expects, as well as how to send them; what port(s) to use, what HTTP methods are used, and what parameters and values are required. With luck, most of the possibilities will be evident by looking at the HTML that you capture from the device.
you would - at least - say the type of that router. jdownloader has a similar functionality, it is implemented in java, probably you can get some tips from there.
I don't understand your answer...
After visiting the site, I still don't (and I can read spanish!).
Could you clarify a bit ?
Creating a smart HTTP client requires a reasonably complete programming language such as Perl, Python, or C. You will need to be able to parse HTML, and this can be tricky, but there are existing libraries for most languages to help out. Perl is my preferred tool for this task. You will need to divine by inspection and trial and error, what responses the device expects, as well as how to send them; what port(s) to use, what HTTP methods are used, and what parameters and values are required. With luck, most of the possibilities will be evident by looking at the HTML that you capture from the device.
Thanks for your fast and complete response.
However, we don't have the time and skills to take this approach.
We've decided to simply export the different configurations from the routers and have an autoclicker load these different files on command...
I don't understand your answer...
After visiting the site, I still don't (and I can read spanish!).
Could you clarify a bit ?
jDownloader includes a feature similar you requested. There is also a script generator to be able to handle any kind of router. So actually the problem is solved, you only need to use that solution (if it was really suitable).
Another solution could be to upgrade the software of the router (that's why I asked the type). In this case you may have ssh into the router.
Another solution could be to upgrade the software of the router (that's why I asked the type). In this case you may have ssh into the router.
We are testing our device for consumers. So we need to test it with the routers in their default firmwares.
What do you mean that jDownloader can 'handle' the routers ? Can it automatically load a previously saved configuration file ?
(Automatically means in this case, triggered by a command from another script ?)
You could write a script which would telnet/ssh into this kinda router - get environemnt variables/set environement variables - check for changes/make changes and logout.
You could write a script which would telnet/ssh into this kinda router - get environemnt variables/set environement variables - check for changes/make changes and logout.
I dont think it is that cumbersome.
I think most routers don't support ssh ?
I've been trying to use curl, mainly to upload a previously saved configuration file (we saved several, all with different settings), but I can't figure out the correct syntax.
This is the command I've deducted from the http header, but I don't think it is correct.
If anyone would be able to correct this syntax, it would be a huge step forward curl --trace -F restore=@Radio_OFF.cfg -F submit_button=Restore -F wait_time=21 http://192.168.1.103:8080/restore.cgi -u adminassword
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.