Script command is not supported by device (JS)

NL
Nicolas LE BIHAN
SYSTEME U CENTRALE NATIONALE

Hi, 

I am having trouble using JS scripts sent to terminals from a package created from McStudio.15.4.1.
What I don't understand is that the same script sent from the WEB console is working, but when it is sent from a PKG I get an error per line of my script in the log.
Below is my script:

#!/usr/bin/env js
var buttonLabels = ['PDV', 'Entrepôt']
var file = new mobicontrol.io.File('/sdcard/EnvironnementInfo.ini');

mobicontrol.message.createInfoDialog('Sélectionner un environement.')
    .withButtons(buttonLabels[0], buttonLabels[1])
    .withWarnIcon()
    .withTitle('Préparation terminaux')
    .withCallback(onConfirm).show();

function onConfirm(result) {
if (result.buttonIndex != null){

file.writeText('[EnvironnementInfo]'
+ '\nEnvironnementInfo = ' + buttonLabels[result.buttonIndex]);

mobicontrol.log.info('EnvironnementInfo:' + buttonLabels[result.buttonIndex]);
mobicontrol.log.info('File exists');
mobicontrol.agent.checkIn()
}
}

Any idea ?

3 years ago
SOTI MobiControl
ANSWERS
ML
Matt Ladwig
3 years ago

When it is the package did you make sure that the 

#!/usr/bin/env js

is on the first line?  When I tried to do this and left the default comments there and put this below the agent didn't recognize it as a javascript script.  But if I deleted out the comments and put that on the first line it worked great.

Z
ZPMOD@SOTI
3 years ago

Hello Nicolas LE BIHAN,

Thank you for requesting a response from SOTI Support Staff.

Tested what Matt Ladwig has pointed out. 

Make sure this is the top line of the script in the package:

#!/usr/bin/env js

remove any of the default text that get added

aka 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pre-Install Script File
; Date Created: Friday, January 7, 2022
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Regards,  

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | www.soti.net |

Z
ZPMOD@SOTI
3 years ago

Hello Nicolas LE BIHAN,

Was the above info helpful for finding a solution to your post?

Regards,  

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | www.soti.net |