JS to pull IP address and execute time sync file based on first 2 octets of IP address.

Hi SOTI Community it's me again lol: I'm new to JS and learning with Code Academy and God! Today I'm struggling with 1. pulling the IP address from my device details page 2. executing a time sync XML file in JS (I already have the time sync file synced to the device). 

This is only pieces of my code that I'm currently working on: The end goal is to be able to:

1. write the device details to a new file on my sd card  ( I have most of this but the IP address is not working)

2. read the contents of the file to grab the ip address ( i think i have this working, it's just pulling wrong information)

3. based on that ip address, execute a specific time zone file ( i don't know how to execute my XML file in JS to apply the time zone on the device)

Here is the code I have so far: 

var folderPath = '/sdcard/DeviceInfo';
var deviceId = mobicontrol.device.id;
var deviceMAC = mobicontrol.device.macAddress;
var ipAddresses = mobicontrol.network.activeNetwork.ipAddresses;
var deviceIP = ipAddresses[0].hostAddress
var xmlString = '<?xml version="1.0" encoding="utf-8"?>\n' +
'<deviceinfo>\n' +
' <device id="' + deviceId + '"/>\n' +
' <device macaddress="' + deviceMAC + '"/>\n' +
' <device ip="' + deviceIP + '" />\n' + '</deviceinfo>';
var xmlFile = new mobicontrol.io.File('/sdcard/DeviceInfo/DeviceInfo.xml');
checkFolder();
function checkFolder() {
var foldercheck = new mobicontrol.io.File(folderPath);
if (foldercheck.exists) {
mobicontrol.log.info('Folder exists');
}
else {
mobicontrol.log.info('Folder does not exist.')
newFolder();
};
}
newFolder();
function newFolder() {
new mobicontrol.io.File(folderPath).createDirectory();
}
xmlFile.writeText(xmlString);
var xmlContent = xmlFile.readText(deviceId);
mobicontrol.log.info('Device ID: ' + deviceId);
 
 
the output for the IP address was working before but today when i try it is giving me this: *i modified the file but everything is showing correct but the IP address* it is not giving me the actual IP anymore of 10.1.X.X
 
Any help at all or a point in the right direction is greatly appreciated!!!
a year ago
Android Scripting
ANSWERS