Skip to content

Instantly share code, notes, and snippets.

@tsjk
Created February 12, 2016 11:14
Show Gist options
  • Save tsjk/6ca9a32bc1c248ce44f8 to your computer and use it in GitHub Desktop.
Save tsjk/6ca9a32bc1c248ce44f8 to your computer and use it in GitHub Desktop.
Rebooting a NETGEAR Gateway CG3700EMR-1CMNDS using CasperJS. Usage: casperjs reboot--CG3700EMR-1CMNDS.js <routerIP> <adminLogin> <admiPassword>
var casper = require('casper').create();
var utils = require('utils');
casper.start();
casper.setHttpAuth(casper.cli.get(1), casper.cli.get(2));
casper.thenOpen('http://' + casper.cli.get(0)).then(function() {
this.echo(this.getTitle() + ': Logged in.');
});
casper.then(function() {
this.wait(1000, function() {
this.echo(this.getTitle() + ': Issuing reboot.');
});
});
casper.thenOpenAndEvaluate('http://' + casper.cli.get(0) + '/RouterStatus.htm', function() {
var f = document.forms[0];
f.buttonSelect.value="2";
f.submit(f);
});
casper.then(function() {
this.echo(this.getTitle() + ': Reboot issued.');
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment