Created
August 6, 2014 17:31
-
-
Save jctosta/db0dce54e4791d3fc2a9 to your computer and use it in GitHub Desktop.
Check Machine Location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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