VtrinCmd Tool

This is an internal tool used to import and export files in JSON format.

The table below shows parameters that are used with VtrinCmd (VtrinCmd[.exe] [parameters]). We have provided some examples further below.

  • Many parameters are available in both short and long form. For example, -c and --connectionstring are equivalent

  • Parameter names are case-sensitive. For example, -u and -U are different parameters.

Parameters

ShortLongDescription
--acceptkeychangesAccept server key changes.
--acceptnewkeysAccept new server keys.
-c--connectionstring <value>Connection string for the driver.
-C--continueonerror(with --importjson option) Continue operation when an error occurs.
-e--exportjson <value>Export JSON class data. "ClassID[properties]:Mask" Multiple separated with | .
--exportjsonbag <value>Export JSON property bag(s) "BagID[VersionTime]:UserID" Multiple separated with.
-T--exportjsontreenode <value>Export JSON from TreeNode instance and other related data. NodeId as parameter.
-F--exporttofolder <value>Export TreeNodes recursively to a folder structure. Folder path as parameter.
-M--fetchmax <value>(with --query option) Maximum number of rows returned by the query.
--fileversionDisplay only the file version (VtrinLib.dll)
-f--force(with --importjson option) Forcefully remove conflicting instances.
-h--helpDisplays all available parameters and usage information.
--hidelinenumbers(with --query option) Don't show line numbers in query results.
-i--importjson <value>Import JSON data from a file(s). Multiple files separated with |
-I--importjsonfolder <value>Import data from .json files in a folder recursively. Folder path as parameter.
--includedefault(with --exportjson option) Include property values identical to default values.
--indent <value>Number of spaces for indent in exporting/displaying JSON data (Tab used by default).
--noconfirmNo user confirmation with --importjson and --removejson options when processing files in folder(s)
--noreplace(with --importjson option) Do NOT replace/merge into existing class instances.
-o--outfile <value>Write output to a file (with export* options).
-q--query <value>Query class data. "ClassID[Properties]:Mask".
--rawvalues(with --query option) Show raw values in query results.
-R--recursive(with --exportjsontreenode) Export recursively the whole sub tree.
--removejson <value>Remove from data source all data found in JSON file(s). Multiple files or directories.
-U--savecredentials(with --connectionstring) Save entered credentials to the credential storage.
--showexamplesShow usage examples.
--taketimeMeasure amount of time taken by the operation.
--traceShow diagnostics trace.
-u--user <value>(with --connectionstring) User for the connection. (When using vault name prefix with *)
--verbose(with --importjson option) Show verbose trace output on console.
--versionDisplay the product version (VtrinLib.dll).

Query language

The query language for --exportjson and --query options is "classid[properties]:mask"

  • Classid = The Id of the source class.
  • Properties = (Optional) List of class properties to include, comma separated in square brackets [].
  • Mask = (Optional) Vtrin where mask string (prefix with : ) for filtering query results.

Further notes for query:

  • Multiple queries are supported and should be separated with | (pipe).
  • The property list supports * (asterisk) wildcard to include matching property names.
  • Property names prefixed with - (dash) are excluded from the results. (Wildcards not supported.)
  • With --query option, only properties visible to user by default are included. Using * in the property list overrides this.
  • NOTE: Unless --includedefault is used --exportjson only includes properties if their value differs from the default.

Connect to Data Source

Connect to a data source using a connection string. You can connect to a remote server or directly to a local data source.

Remote Connection

Connect through a Vtrin Server WebSocket endpoint.

VtrinCmd --connectionstring wss://server/history

Local Connection

You can connect locally through the View endpoint or directly to the data source.

WebSocket to Vtrin Server

Works on both Windows and Linux and does not require direct access to database files.

VtrinCmd --connectionstring wss://localhost/view

Direct RTDB connection

Can be used when the View connection is not available, for example when the Vtrin Server is stopped.

VtrinCmd --connectionstring "%APP_DATAPATH%"
runcpm VtrinCmd --connectionstring /var/lib/rtdbdata

On Linux, direct RTDB connection must be executed using runcpm.


Authentication

When connecting through a WebSocket endpoint (wss://), use the --user option if credentials are not saved. The password will be prompted separately.

VtrinCmd --connectionstring wss://server/history --user myuser

Direct RTDB connection do not require a username or password.


Credentials

Credentials can be saved for reuse when connecting to data sources that require authentication. When saving credentials VtrinCmd prompts for the username and password.

VtrinCmd --connectionstring wss://server/history --savecredentials

Self-signed Certificates

If the connection fails because the server certificate is not trusted (for example, when using a self-signed certificate), use the --acceptnewkeys option when connecting for the first time.

VtrinCmd --connectionstring wss://server/history --savecredentials --acceptnewkeys

Good to know:

  • After a successful connection, you can choose a name for the stored credentials.

  • Saved credentials can later be used with the --user option by adding * before the credential name.


Usage Examples

Export Equipment and PropertyInfo

This example exports all Equipment and EquipmentPropertyInfo class instances and store the output to equipment.json file.

VtrinCmd --connectionstring wss://myserver/mysource --exportjson "Equipment|EquipmentPropertyInfo" --outfile equipment.json

Import data

This example imports data from equipment.json to the connected data source.

VtrinCmd --connectionstring wss://myotherserver/mysource --importjson equipment.json

Export CalculationTask instances

This example exports all CalculationTask instances whose Module is 'MyModule'. However excluding RowModificationTime from the export.

VtrinCmd --connectionstring wss://myserver/mysource --exportjson "CalculationTask[-RowModificationTime]\:Module = 'MyModule'"

Listing Path_ names

This example lists the names and base class names of classes whose name begin with string "Path_" in descending order by name.

 VtrinCmd --connectionstring wss://myserver/mysource --query "Class[Id,BaseClassName]\:Id LIKE 'Path\_\*' ORDER BY Id DESC"

Listing System Instances

This example lists all System instances showing values for ComputerName and any property containing word "disk".

 VtrinCmd --connectionstring wss://myserver/mysource --query "Path_ABB.Ability.SysDiag.System[ComputerName,*disk*]"

Further Reading:


Did this page help you?