How to programmatically identify if a TERR script is running locally or on the TSSS server.

How to programmatically identify if a TERR script is running locally or on the TSSS server.

book

Article ID: KB0080512

calendar_today

Updated On:

Products Versions
Spotfire Analyst All supported versions
Spotfire Statistics Services All supported versions

Description

In some scenarios, it might be required to detect in the script itself whether a Spotfire data function's TIBCO Enterprise Runtime for R (TERR) script is being executed by the Spotfire desktop client's own built-in local TERR engine or sent out to a TIBCO Spotfire Statistics Services (TSSS) instance on a server. 
 

Environment

All supported environments

Resolution

TERR's grepl() function can be used to achieve this requirement. 

The following command can be used to test whether or not a data function's TERR script is being sent to the desktop client's own local TERR engine or sent out to a TSSS/TERR instance:


    grepl( "Modules", Sys.getenv( "TERR_HOME" ) )

This call to grepl() looks for the string "Modules" in the "TERR_HOME" environment variable. A default TERR_HOME path in a TSSS/TERR instance will not include the "Modules" string, but the TERR_HOME path in the desktop client's local TERR engine will.

If the above command returns TRUE, the data function is using the Spotfire desktop client's local built-in TERR engine.

 

Issue/Introduction

How to programmatically identify if a TERR script is running locally or on the TSSS server.