Skip to content

Instantly share code, notes, and snippets.

@jctosta
Created August 6, 2014 17:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jctosta/db0dce54e4791d3fc2a9 to your computer and use it in GitHub Desktop.
Save jctosta/db0dce54e4791d3fc2a9 to your computer and use it in GitHub Desktop.
Check Machine Location
#!/usr/bin/env node
var args = process.argv.slice(2);
//console.log('Started');
// String startsWith polyfill
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
value: function (searchString, position) {
position = position || 0;
return this.lastIndexOf(searchString, position) === position;
}
});
}
var os = require('os');
var ifaces = os.networkInterfaces();
var wlan = ifaces['wlan0'];
if (wlan !== undefined && wlan !== null) {
var wlan_address = ifaces['wlan0'][0].address;
//console.log(wlan_address);
if (wlan_address.startsWith("10")) {
console.log("Dataprev");
//process.stdout.write("Hello");
} else {
console.log("External");
}
process.exit(0);
} else {
console.log("Interface Not Found.");
process.exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment