Table of Contents
The Software Discovery Language™ (SDL) is an interpreted scripting language implemented in SysInfo™ to discover software products. SysInfo™ uses SDL scripts to discovery and collect SysInfo™ Software class data for software products which do not register themselves with the native operating system software registry (Windows Registry, RPM, swinstall, pkgs, etc).
SDL scripts are interpretted at runtime and thus are able to be added, deleted, and modified to an existing SysInfo™ binary installation. Customers can choose to add and maintain their own set of SDL scripts to support their specific environment and applications.
The primary work of an SDL script is to discovery it's intended software product. The script can use many of the SDL standard functions or the programmer can write their own custom functions built on top of the SDL standard functions much like in a shell script.
When an SDL script discovers data about it's intended software product, it
uses a series of SDL standard functions to record the relevent data.
When all of the relevent data is discovered, the SDL script calls the
SoftInfoAdd()
to add the discovered product to the internal software list.
When all Software discovery, both SDL and the discovery built into SysInfo™,
is complete, the discovered products are reported.
By convention each SDL script should discover and report on a single software product. While there is no SDL syntax limitation to supporting multiple products in a single SDL script, this is not yet a supported convention.
An SDL script is a text file which has a syntax that is a blend of C and UNIX Bourne Shell syntax.
An SDL script contains a series of statements. Statements can contain variables, custom functions, and calls to custom or standard SDL functions. Statements are terminated by the ';' (semi-colon) character. Statements can be grouped together inside of '{}' (curly braces).
The "//" (two forward slashes) sequence denotes a comment. Anything appearing after this sequence on the same line is ignored.
A fairly simple SDL script with builtin product definetions is:
Example 22.1. Simple SDL Script example
$PRODUCT_NAME = "splicer"; // Required $VENDOR_NAME = "Acme Inc"; // Required $SoftInfo = SoftInfoCreate($PRODUCT_NAME, "1.0"); SoftInfoAdd($SoftInfo); Exit(0);
In this example, a product called "splicer" version 1.0 is created and
added to the list of products to report.
Note that the call to SoftInfoAdd()
is always
required in order to report on the discovered product. If you do not
call the SoftInfoAdd()
function your product will
not be reported by SysInfo™.
SDL supports the following data types:
Table 22.1. SDL Data Types
Type | Description |
---|---|
Boolean_t | Value can either by True or False. |
String_t | A string value. |
Array_t | An array of any other supported data type. |
Number_t | A numeric integer or floating point value. |
XmlHandle_t | A handle used to manipulate XML data. |
SoftInfo_t | A handle used to manipulate discovered software data. |
DataTree_t | A generic list of data in a hierarchy tree structure. |
Variables have local function scope. A variable declared in the global scope is available through-out the entire script. A variable declared inside a function has a scope limited to that function.
Variable names start with the traditional '$' and consist of letters, digits, and '_' (underscore) characters. Variables are set using the '=' (equal) char and can be set to literal string or numeric values, as well as to other variables or data returned by functions.
Example 22.2. Variable Names
$String1 = "fun time"; $Num = 42; $MyStrArray = StrSplit(":", "/usr/bin:/bin:/etc");
SDL supports the
if
,
if else
,
for
,
foreach
,
and
while
,
logical constructs.
IF statements are logical conditional statements that are very similiar to C statements. The syntax supports both a simple "if" conditional as well as an "if else" syntax.
FOR statements are logical conditional loop statements that are very similiar to C statements. The syntax is as follows:
Example 22.5. FOR Syntax
for ([first time statements]; [while true]; [loop statements]) { [statements] }
FOREACH statements are logical conditional loop statements that are very similiar to the Perl "foreach" loop. The FOREACH statement takes a single value which must be an Array_t value of any supported type. Each value in the Array_t is iterated until the end of the array is reached or a "Break" or "Return" statement is reached. Each time through the loop the first argument is set as a variable specifying the value of the iterated array. The syntax is as follows:
WHILE statements are logical conditional loop statements that are very similiar to C while loops. The statements inside the while loop are executed so long as the logical loop test evaluates to true. The syntax is as follows:
There are a number of special instructions which apply to the
loop constructs
for
,
foreach
,
and
while
.
When the break
instruction is encountered inside
of a loop, the execution of that loop immediately stops and continues after
the loop construct.
When the continue
instruction is encountered inside
of a loop, the executation of the loop returns to the "top" of the loop
instead of contining to the next logical statement inside of the
loop.