Looking for a way to use variables in scripts on Android+/Enterprise

Solved
LN
Laurent, NACHBAUER
Solutys Technologies

Hi,

I'll explain the context which tells why this would be much appreciated.

We use relay ftp servers on multiple shops (one for each shop) that receive app updates.

These updates are to be downloaded to the devices and then installed.

Each shop has its own IP subnet, but the last ip octet is always the same.

The local FTP server address is known be the device in an INI file from one of the apps.

The goal is to script a ftp get using the value of the IP address contained in the INI file as a variable so that only one script is needed instead of... many, one per shop.

Problem is : the "set" script command is not working on Android so I couldn't find a way to do it yet.

The %ip% of the device is working, but I couldn't find a way to extract the string and modify it. Everything needs variables.

If anyone has an idea, would be very much appreciated.

Edited 7 years ago
Android
ANSWERS
RC
Raymond Chan Diamond Contributor
7 years ago (edited 7 years ago)

The simplest solution for your use case is to use custom attribute.  

Example 1 -

Create one called ftp_ip and with type string, and allow its value to be propagated to device.  Set the value by device/device-group ( or by bulk import with CSV file if you are using Mobicontrol version earlier than v14).

Assume all devices locating to one particular shop use the ftp server with IP address 192.168.10.200 , just set the custom attribute ftp_ip for all these devices to "192.168.10.200". 

Then, in your global Android+ script to be used for ALL shops, just refer to this ftp address as

  %CustomAttr:ftp_ip%

Example 2 -

Assume all ftp servers use ftp address 192.168.X.200 with X  being the subnet address of the shop. Then you can add a custom attribute ftp_subnet of type string/integer.  Set value to be in the range 0 to 254

Then, in your global Android+ script to be used for ALL shops, just refer to this ftp address as

   192.168.%CustomAttr:ftp_subnet%.200

Solution
LN

Sounds like great ideas thank you, I will try that today.

OS is Nougat 7.1.2 under Android Enterprise agent, btw.

Will report back later.

SS
Support Staff Account
7 years ago (edited 7 years ago)

Hello Laurent, 

What OS version is running on these devices?

LN

I tried at first with custom attributes but couldn't get the syntaxe of the variable to work, then I talked to our presales tech @soti, and got some more documentation on the subject.

There I saw that custom data should work too, which is even better.

I used 3 custom data to get server IP, user and pwd from the INI file, and used that in the script command :

ftp get -o ftp://%MCCustomData:UPDATE_USR%:%MCCustomData:UPDATE_PWD%@%MCCustomData:UPDATE_IP%/OMPV_v1.7.2.apk %sdcard%/Update_GD/OMPV_v1.7.2.apk

install %sdcard%/Update_GD/OMPV_v1.7.2.apk

It is working perfectly fine.

I want to thank you for your help, it really solves a big problem for us.

RC
Raymond Chan Diamond Contributor
7 years ago

Using custom data in the way you described can have all required parameters maintained in a single ini file to each target device.  However, possible drawbacks are:

1. The need to set up file-sync rule or other way to get the right ini file on the device.

2. The ini file might be easily readable/modifiable by other apps on the device, or by any unintended person holding the device unless proper security measures are taken.

3. Possible impact on battery life on the device if scheduling of  data-collection or file-sync is set too high or left active when not needed.

On the contrary, maintaining your parameters with custom attributes can be done directly on the web-console, and the parameter values are under total control of Mobicontrol administrators with the right permission.

LN

Because of the use of static IP addressing, we have a deployment tool that automatically sets up the IP settings (via xml setup), and patches the ini files initially, at the early setup process before sending them to the shops. They never change and stay that way for the life of the device.

So this is not a problem. Devices are under lockdown screen, so the users cannot do anything we don't let them.

About the battery life, we are aware of that, not a problem either, the batteries last long enough for a full working day with plenty of room, and are charged at night.

M
Markus
7 years ago

Hi

Did that worked for someone with the  custom attributes?

In my test the variable is empty:

echo %CustomAttr:TestVar%

The flag "Propagate to Device" is checked. We work with Android Plus with Android 7.1.2

Thank you

Markus

RC
Raymond Chan Diamond Contributor
7 years ago

Works with all 4.x+ Android versions.

How did you run your "echo" command?   Did you wait long enough (i.e. until next scheduled update) or manually perform any device check-in to make sure the value set via your Web-console get updated onto your test device?

Also, the attribute name is case sensitive. A simple typo using wrong case for even one character will render an empty value returned.

M
Markus
7 years ago

Hi

I tried it in the messagebox and on the remote console cli with echo %CustomAttr:TestVar%.

Yes, i waited until a device checkin.

But it didnt worked

Thank you

.

RC
Raymond Chan Diamond Contributor
7 years ago

Hi Markus,

Could you show a screenshot of the value configured for "TestVar" associated with your test device?

M
Markus
7 years ago

Hi Raymond

Global Custom Attributes

I defined a Value direct on the device

Is empty

we use MobiControl 14.1. Perhaps this is the difference

RC
Raymond Chan Diamond Contributor
7 years ago

I've tested again on a v14.1.0.1152 server and confirmed that the custom attribute value set is not "automatically" updated onto the targeted device on device check-in's (whether automatically scheduled or manually initiated) .  

 However, I've also confirmed that the script command "echo %CustomAttr:TestVar%" still works once the custom attribute value is pushed onto the device for this v14.1 version.

I've just reported the issue to Soti support team.   Please wait for fix in future release. 

M
Markus
7 years ago

Thank you very much

RC
Raymond Chan Diamond Contributor
7 years ago

I got reply from Soti support earlier today (11 Apr 2018) and I did some tests.

The issue of custom attribute value not propagating to device is solved for MobiControl server version v14.1.2.1937.


Note : Device agent may need to be updated. On my Samsung test phone, it still fails when agent version is v13.5.0.1088, but is OK for the more recent v13.5.0.1327.

DV
Dennis Vdh
6 years ago (edited 6 years ago)

Raymond, was this issue solved eventually?

I'm having similar issues on Mobicontrol v14.4.0.4857
Agent v14.0.0 Build 1579

  • "test" CustomAttribute setup + Propagate to devices
  • Assign a value (AAA) to device or device group
  • echo "%CustomAttr:test%" --> displays "AAA"

  • Update value "AAA" to "BBB" + device Checkin
  • echo "%CustomAttr:test%" --> displays "AAA"

So initially value gets propagated, but afterwards it does not get updated.