Product Documentation

Examples of Simple Mortscripts

Dec 21, 2015

Ask for Reboot Script Example

Result=Question("Your device needs to be rebooted. Do you want to reboot now?", "Hello %{ user.name? | protect('"', '"') | encode('UTF-8') }%!", "YesNo")

If ( Result=YES)

Reset

EndIf

This script opens a dialog box with the Yes and No buttons. It asks for the user to reboot now or later. If Yes is pressed, the device will reboot. If No is pressed, nothing happens except that the dialog is closed.

The title of this dialog displays the name of the user, as stored in a custom property of the user.

Data Upload Script

Here is an example of a Mortscript script used to upload a file to a FTP server:

FtpUpload("My Documents\test.zip", "incoming/file.zip", "ftp.mydomain.com", "test", "test", TRUE)

This simple script will upload the file test.zip, located in the directory “My Documents” of the device, to the server ftp.mydomain.com, in the directory “incoming”. The file will be renamed file.zip. It will use the login “test”, and password “test”, and use the passive mode of the ftp protocol.

The synopsis of the FtpUpload function is the following:

FtpUpload( source file, target file, server, [ user [, password [, passive? [, port] ] ] ] )

Note: In this Device Manager release, the FtpUpload function is not yet part of the standard Mortscript program but is only available in the Device Manager release of MortScript.