"if exist" script on Android Enterprise

Solved
7
74HCT04
Jersey Post

Hi,

I am trying to come up with a method to identify whether a specific file is present on a fleet of Honeywell CT60 Android Enterprise devices running Android 9. I need to be able to identify which devices have the file using a Log Information Report (or similar).

I was hoping that the solution would be to run a legacy script along the lines of:

if exist "/sdcard/Android/data/com.vendor.myapp/files/LogonData.ini" echo "LogonData.ini exists"

but this returns the error 'Script command is not supported by device (if).'

A directory listing like the ls command with output sent to the logs would also be ideal.

Any suggestions would be gratefully received, thank you.

3 years ago
Android Scripting
ANSWERS
CR
Chris R.
3 years ago

You can try something like this with javascript:

var file = new mobicontrol.io.File('/sdcard/Android/data/com.vendor.myapp/files/LogonData.ini');
     if (file.exists) {
         mobicontrol.log.info('LogonData.ini exists');}
         else { mobicontrol.log.info('LogonData.ini does not exist.');
}

Solution
7
74HCT04
3 years ago

Thanks very much Chris R. your solution worked perfectly!

I've modified the javascript to also output the file size as this will actually be used to determine whether or not a ~1.5GB firmware upgrade has downloaded, and has done so fully. The .ini file was just an example I had to hand.

var file = new mobicontrol.io.File('/sdcard/Android/data/com.vendor.myapp/files/LogonData.ini');
     if (file.exists) {
    mobicontrol.log.info('LogonData.ini exists');
    mobicontrol.log.info('File size: ' + file.size);}
    else { mobicontrol.log.info('LogonData.ini does not exist.');
}

N
NTMOD@SOTI
3 years ago

Hi 74HCT04,

Thank you for your post on SOTI Central.

Hi Chris R.,

Thank you for providing the script and resolve the issue for 74HCT04.

Kind Regards,