Programming Service Scripts

Top  Previous  Next

 

A script file must be specified when running Robo-FTP as a service. Special considerations apply when programming a script to be used in a service:

 

Continuous looping

A typical deployment of Robo-FTP as a service uses a script that runs in a continuous loop.  One common design for service scripts uses either the CRON or PAUSE script commands to suspend processing and then later awaken to perform one or more tasks at a specified time or date.  Once the task is complete, the script loops back and is suspended until the next period of activity.

 

Service scripts are also often designed for real-time processing so they are always looking for something to do.  For example, the hot send and hot receive styles of service script constantly poll a folder for new files and then react accordingly when a new file is discovered.

 

 

Permissions

File and folder permissions must be considered when selecting the credentials under which the service will run. The LOCAL SYSTEM account is the default for Robo-FTP services and it can interact with the desktop.  Interaction with the desktop is not possible if you specify a user account under which the Robo-FTP service is to run. On the other hand, the LOCAL SYSTEM account typically does not have access to network resources.

 

Unless you install the service with the Permit Interaction With Desktop option selected, interactive script commands such as ASK and PROMPT are not permitted in service scripts. Windows Vista and later operating systems require the user to authorize each of Robo-FTP's attempts to interact with the desktop.

 

Important

All services run in Terminal Services session 0. Therefore, if an interactive service displays a user interface, it is visible only to the user who connected to session 0. Because there is no way to guarantee that the interactive user is connected to session 0, do not configure a service to run as an interactive service under Terminal Services or on a system that supports fast user switching (fast user switching is implemented using Terminal Services).

 

 

Error handling

The IFERROR command is a powerful tool in service scripts designed for unattended execution.  Use this command to catch and recover from potential failures including network outages and unexpected changes to login credentials or permissions.  Many developers choose to send an automated email message alerting support staff when an unrecoverable error occurs.

 

Important

It is strongly recommended that you exhaustively test any script file that you intend to run as a service in the normal Robo-FTP console window before using it as a service.

 

 

Monitoring and logging

Unlike other Windows services, the Robo-FTP service does not log all results and errors to the System Event Log. Instead, you should use the LOGMSG, DASHBOARDMSG, or LOGNTEVENT script commands to monitor operation of a Robo-FTP service that does not interact with the desktop. Services launched from the command line should include the SRVNAME command.

 

Logging is an importing tool for diagnosing problems with service scripts because they are typically run without the normal Robo-FTP console window interface. The LOG, TRACELOG and SESSIONLOG script commands are used to control logging.

 

 

Halting a service

Typically a running Robo-FTP service will remain active until the script executes the EXIT command. The STOP command should never be used from a service script.  A service may be stopped manually using the Windows Service Manager, the Service Installer or the Enterprise Dashboard.

 

If your script logic contains steps that must not be interrupted, you can design it to use a special shutdown script for orderly termination.

 

 

See also: Installing Robo-FTP as a Service