Loading the library
The library is loaded using the following directive :
assuming that /usr/bin is in your path.
Once the library is loaded, every sysfunc commands are available, prefixed with the 'sf_' string.
Calling a single function
It is possible to call a single function without preloading the library. The syntax to use is :
where <command> is the name of a sysfunc function to call, without the'sf_' prefix.
The following line creates or updates the 'myvar' DB variable with the current time :
The second form will be preferred when using several function calls in a script, as it is faster and avoids specifying 'sysfunc ' before every commands. The first form is easier to use when calling a single command, from the command line for instance.
Checking whether the library is loaded
The sf_loaded function checks if the library is loaded. When using this function, you must redirect stderr to /dev/null to avoid displaying an error when the library is not loaded (when the library is not loaded, the function won't be found).
The syntax to use is:
This sets $? to 0 if the library is loaded, and to 1 if not. So, you can conditionally load the library using a line like :
This line causes the library to be loaded only if it was not done already.
Tip: When dealing with a set of several shell scripts, include such a directive at the beginning of every script which use sysfunc functions. This way, you ensure that the sysfunc commands are available when you need them, but the library is loaded only once.