http://zorba.io/modules/system

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace system = "http://zorba.io/modules/system";
The system module allows developers to access system properties. Part of these system properties are environment variables, local variable to the process running Zorba, and properties defined by Zorba.

To avoid conflicts between environment variables and properties defined by Zorba, all environment variables are prefixed with env..

For instance, the following query:

 import module namespace system = "http://www.zorba-xquery.com/modules/system";
 for $prop in system:properties()
 return concat($prop, ": ", system:property($prop), "
 ")
 

Will output:
 env.TERM_PROGRAM: Apple_Terminal
 ...
 
In this example, it is important to notice that the environnement variable PATH with the key env.PATH.

Module code

Here is the actual XQuery module code.

Authors

Markus Pilman

Version Declaration

jsoniq version "1.0" encoding "utf-8";

Namespaces

anhttp://zorba.io/annotations
systemhttp://zorba.io/modules/system
verhttp://zorba.io/options/versioning

Variables

system:OS-NAME as xs:string

The name of the operating system (os.name).

system:OS-NODE-NAME as xs:string

The name of the computer the process is running on (os.node.name).

system:OS-VERSION-MAJOR as xs:string

The major version number of the Windows installation or an empty string if the process does not run on a Windows installation (os.version.major). Works on Windows only.

system:OS-VERSION-MINOR as xs:string

The minor version number of the Windows installation or an empty string if the process does not run on a Windows installation (os.version.minor). Works on Windows only.

system:OS-VERSION-BUILD as xs:string

The build number of the Windows installation or an empty string if the process does not run on a Windows installation (os.version.build). Works on Windows only.

system:OS-VERSION-RELEASE as xs:string

The release of this UNIX installation or an empty string if the process does not run on a UNIX/Linux installation (os.version.release). Works on UNIX based operating systems only.

system:OS-VERSION-VERSION as xs:string

The version of this UNIX installation or an empty string if the process does not run on a UNIX/Linux installation (os.version.version). Works on UNIX based operating systems only.

system:OS-VERSION as xs:string

The version of the Operating System.

system:OS-ARCH as xs:string

The name of the processor architecture (os.arch). For example x86 or x86_64.

system:OS-IS64 as xs:string

True if system architecture is 64bits (os.is64).

system:HARDWARE-LOGICAL-CPU as xs:string

Number of logical processors in the system (hardware.logical.cpu). This information is not available under Mac OS X.

system:HARDWARE-PHYSICAL-CPU as xs:string

Number of physical processors in the system (hardware.physical.cpu).

system:HARDWARE-LOGICAL-PER-PHYSICAL-CPU as xs:string

number of logical per physical processors in the system (hardware.logical.per.physical.cpu). This information is not available under Mac OS X.

system:HARDWARE-PHSICAL-MEMORY as xs:string

Physical memory available (hardware.physical.memory).

system:HARDWARE-VIRTUAL-MEMORY as xs:string

Virtual memory available (hardware.virtual.memory).

system:HARDWARE-MANUFACTURER as xs:string

Gets the hardware manufacturer (hardware.manufacturer).

system:LINUX-DISTRIBUTOR as xs:string

The Linux distribution, Zorba is running on (linux.distributor). Works on UNIX based operating systems only.

system:LINUX-DISTRIBUTOR-VERSION as xs:string

The version of the Linux distribution, Zorba is running on (linux.distributor.version). Works on UNIX based operating systems only.

system:USER-NAME as xs:string

The username, with which this process was started (user.name). On Unix, this variable is only available if the USER environment variable is set (e.g. it might not be available in a cronjob).

system:ZORBA-MODULE-PATH as xs:string

The Zorba module path, that is the paths in which Zorba looks for modules (zorba.module.path).

system:ZORBA-VERSION as xs:string

Zorba version in the format Major.Minor.Patch (zorba.version).

system:ZORBA-VERSION-MAJOR as xs:string

Zorba major version (zorba.version.major).

system:ZORBA-VERSION-MINOR as xs:string

Zorba minor version (zorba.version.minor).

system:ZORBA-VERSION-PATCH as xs:string

Zorba patch version (zorba.version.patch).

Function Summary

property($key as xs:string) as xs:string? external

Gets the system property indicated by the specified key.

properties() as xs:string* external

This function retrieves the names of the current system properties.

all-properties() as object()

This function retrieves all names and values from the current system properties.

Functions

property#1

declare %an:nondeterministic function system:property(
    $key as xs:string
) as xs:string? external

Gets the system property indicated by the specified key.

Parameters

  • $key

    The name of the system property.

Returns

  • xs:string?

    The string value of the system property, or an empty sequence if there is no property with that key.

properties#0

declare %an:nondeterministic function system:properties() as xs:string* external
This function retrieves the names of the current system properties. This list includes environment variables, local variable to the process running Zorba, and properties defined by Zorba.

To avoid conflicts between environment variables and properties defined by Zorba, all environment variables are prefixed with env..

Returns

  • xs:string*

    List of all system properties.

all-properties#0

declare %an:nondeterministic function system:all-properties() as object()
This function retrieves all names and values from the current system properties. This list includes environment variables, local variable to the process running Zorba, and properties defined by Zorba.

To avoid conflicts between environment variables and properties defined by Zorba, all environment variables are prefixed with env..

Returns

  • object()

    List of all system properties as a JSONiq Object sequence.