3

I have an old router that I have set up as an AP on my home network. For some reason it loses connectivity every few days and needs a reboot.

I would like to set up a script to run once every night to do this automatically.

I can open the my browser (iceweasel) and navigate to my admin page of the router from the terminal:

iceweasel http://admin:password@192.168.1.1/WLG_adv.htm

On the page that this command opens there is a button with this code:

<input onclick="return checkData();" name="Apply" value="Apply" type="submit">

Is there a way of performing the same action as this button from the terminal? I'm using a Debian Linux.

Ketan
  • 9,226
sam
  • 31
  • 1
  • Yes. You should emulate the checkData() javascript function with another scripting language and then put it to cron. – Mohammad Etemaddar Apr 07 '14 at 13:12
  • 3
    Both jmeter and selenium can automate HTTP requests. I don't have a complete answer but if you wanted a direction to go into, there you go. – Bratchley Apr 07 '14 at 13:13
  • 2
    @MohammadEtemaddar it's actually usually a little more complicated than that. With these webui's you typically have to authenticate, get a cookie representing your authenticated session, then go and emulate the checkData() call (which itself the OP may not be able to properly figure out). If the site uses CSRF then it gets even more complicated. It's definitely still possible, but it's easier to use tools that have taken these things into consideration. – Bratchley Apr 07 '14 at 13:19
  • I think an easier way would be to figure out if your router supports text-mode configuration via telnet and try to automate that. – Joseph R. Apr 07 '14 at 16:27
  • With only what you've posted, all we can do is point to generic web scraping frameworks. Many routers also have a command line interface, that would be the easiest way to automate things. It's also possible that all you need to do is a POST request containing the content of the form (if you can simulate what checkData does — with a name like this, there's a chance that it only performs validation and the submitted form is easy to prepare). If you tell us exactly what router model you have and give us a way to see what that web page contains (including all relevant JS), we might help more. – Gilles 'SO- stop being evil' Apr 07 '14 at 20:25
  • If you have Telnet or SSH access it would be easier. – Braiam Apr 07 '14 at 21:52

0 Answers0