Scripting with a Remote ODT

Overview

The ODT Service of CopyWrite on Windows NT implements an MCP  Remote ODT on Windows NT.

An ODT Command issued from an A-Series, is passed to the ODT Service, which uses the Command as a Key to find a VBScript that implements the Command.

For example, this is the response from a WM Command issued to the remote Host called CPNTA.

Response returned at 10:56:38

=>AT CPNTA WM
System: Microsoft Windows 2000, Uniprocessor Free
Type: ServerNT
Release: 5.0 Build 2195 Service Pack 2
Organization: Metalogic S.a R.L.
Owner: Metalogic
Directory: C:\WINNT
Computer Name: METALOGIC
Processors: 1
Model: x86 Family 6 Model 8 Stepping 6, GenuineIntel
CPM 0: 701 MHz
Script Engine: VBScript Version 5.1.5907
DLRoot: C:\ASeriesBackup
TimeZone: GMT Standard Time

The VBScript which implements this command is called WM.odt,

Option Explicit
 Const HKEY_LOCAL_MACHINE = 2
 Const NT_CurrentVersion_Key = "\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
 Const NT_ProductOptions_Key = "\SYSTEM\CurrentControlSet\Control\ProductOptions"
 Const NT_ComputerName_Key = "\SYSTEM\CurrentControlSet\Control\ComputerName\
 ActiveComputerName"
 Const NT_Environment_Key = "\SYSTEM\CurrentControlSet\Control\Session Manager\
 Environment"
 Const NT_CPM_Key = "\HARDWARE\Description\System\CentralProcessor\0"
 Const NT_TimeZoneInformation_Key = "\SYSTEM\CurrentControlSet\Control\
 TimeZoneInformation"
 
 Function GetScriptEngineInfo
 Dim Text
 Text=""
 Text=ScriptEngine & " Version "
 Text=Text&ScriptEngineMajorVersion & "."
 Text=Text&ScriptEngineMinorVersion & "."
 Text=Text&ScriptEngineBuildVersion
 GetScriptEngineInfo=Text
 End Function 'GetScriptEngineInfo
 
 Dim Registry
 Sub WM
 Dim ProductType,Config
 Set Config=CreateObject("CopyWriteInterface.ConfigurationX")
 Set Registry=CreateObject("CopyWriteInterface.RegistryX")
 Registry.RootKey=HKEY_LOCAL_MACHINE
 
 If Not Registry.OpenKey(NT_ProductOptions_Key,FALSE) then
 Spout("Invalid Key " & NT_ProductOptions_Key)
 Exit Sub
 End If
 ProductType=Registry.ReadString("ProductType")
 
 If Not Registry.OpenKey(NT_CurrentVersion_Key,FALSE) then
 Spout("Invalid Key " & NT_CurrentVersion_Key)
 Exit Sub
 End If
 Spout("System:         "&Registry.ReadString("ProductName")&", 
                                             "&Registry.ReadString("CurrentType"))
 Spout("Type:          "&ProductType)
 Spout("Release:       "&Registry.ReadString("CurrentVersion")&" Build "&Registry.
 ReadString("CurrentBuildNumber")& "  "&Registry.ReadString("CSDVersion"))
 Spout("Organization:  "&Registry.ReadString("RegisteredOrganization"))
 Spout("Owner:         "&Registry.ReadString("RegisteredOwner"))
 Spout("Directory:     "&Registry.ReadString("SystemRoot"))
 If Not Registry.OpenKey(NT_ComputerName_Key,FALSE) then
 Spout("Invalid Key " & NT_ComputerName_Key)
 Exit Sub
 End If
 Spout("Computer Name:      "&Registry.ReadString("ComputerName"))
 If Not Registry.OpenKey(NT_Environment_Key,FALSE) then
 Spout("Invalid Key " & NT_Environment_Key)
 Exit Sub
 End If
 Spout("Processors:         "&Registry.ReadString("Number_Of_Processors"))
 Spout("Model:              "&Registry.ReadString("Processor_Identifier"))
 If Not Registry.OpenKey(NT_CPM_Key,FALSE) then
 Spout("Invalid Key " & NT_CPM_Key)
 Exit Sub
 End If
 Spout("CPM 0:              "&Cint(Registry.ReadInteger("~MHz")) & " MHz")
 Spout("Script Engine:      "& GetScriptEngineInfo)
 Spout("DLRoot:             "&Config.DLRoot)
 If Not Registry.OpenKey(NT_TimeZoneInformation_Key,FALSE) then
 Spout("Invalid Key " & NT_TimeZoneInformation_Key)
 Exit Sub
 End If
 Spout("TimeZone:           "&Registry.ReadString("StandardName"))
 
 End Sub
   

When an ODT Command is received, the ODT Service starts the Scripting Host and creates a Script Object, a TD830 Object and an Intercom Object, all of which it adds to the Scripting Host.

The Methods and Properties of these objects are only available to a VBScript executed in an ODT Service Script.

In the example above, the Spout() Method of the Script Object is used to Display a message on the originating station.

The Methods and Properties of the Script, TD830 and Intercom Objects are described later in this section.

In addition to the intrinsic ODT Service objects, there are VBScript Objects available for accessing the Windows environment, and the CopyWriteInterface ActiveX Automation Objects for accessing A-Series Volumes.

Script Object

The Script Object provides these Methods.

Methods
Method Description Example
PROCEDURE 
    Spout(Const Text:String)
The Text is displayed on the originating station. Spout("A response to an ODT Command")

The Script Object provides these Properties.

Properties
Property Description Example
CommandKey:String; The command key is the first keyword on the command line. The command 'Test What' has a command key of Test. Spout("Command Key >"&CommandKey&"<")
Command Key <Test>
CommandData:String; The command data is the text following the Command Key. The command 'Test What' has command data of What. Spout("Command Data >"&CommandData&"<")
Command Data <What>

TD830 Object

The TD830 Object does not yet provide any Methods or Properties.

Intercom Object

The Intercom Object provides these Methods.

Methods
Method Description Example
<none> <none> <none>

The Intercom Object Properties are mapped to the fields of the Controller Message received by the Remote ODT.

Many of the Properties are documented in the A-Series DCALGOL Programming Reference Manual, in the sections which describe the SETUPINTERCOM Function and the MESSAGE FROM CONTROLLER RESULT.

Properties
Property Description Example
MsgType:Integer; The MsgType Msg[0].[47:8] field is always 21, SETUPINTERCOM Controller Message.
MsgVariant:Integer; The Variant Msg[0].[39:8] field is 2, Input request to the CONTROLLER for processing the message.
MCSNumber:Integer; TheMCS number is in Msg[0].[31:8].
MCSTag:Integer; The Tag Msg[0].[23:9] field is used by the sending MCS for internal purposes. When a reply to this message is sent, this field is included in the reply.
LSN:Integer; The originating LSN in Msg[0].[14:15].
DialogNo:Integer; This is a unique Dialog Number in Msg[1].[43:23] used by CopyWrite to identify an ODT Session.
Response:Integer; The Response Msg[1].[19:4] field.
1 - No response to the message
2 - Concise response (OK)
3 - Expanded Response
LineWidth:Integer; The LineWidth Msg[1].[15:8] field in the range 3..79.
PageLength:Integer; The PageLength Msg[1].[7:8] field gives the number of lines on the page, in the range 1..24..
Format2:Boolean; The Format2 Msg[0].[39:1] field is always TRUE.
Truncate:Boolean; The Truncate field.
Unrestricted:Boolean; The Unrestricted Msg[1].[46:1] field. If set, the user can issue any command, otherwise restricted to those marked as FREE in the SCTABLEGEN.
HasCommandText:Boolean; If there is command text.
HasUsercode:Boolean; If there is a Usercode.
HasLanguage:Boolean If there is a Language.
HasSessionNo:Boolean If there is a SessionNo.
HasReturnLSN:Boolean; If there is a return LSN.
HasSpecialAction:Boolean; If there is special action.
CommandText:String; The text of the command. It includes the command name and following text. Spout("Command Text >" & CommandText)
Command Text >Test Parameters
UserName:String; The Usercode of the initiator. This is typically the HU of the originating host. Spout("UserName is " & UserName)
ServiceName:String; The name of the service from the Connect Request. The service name is always ODT. Spout("ServiceName is " & ServiceName)
ServiceName is ODT
FunctionName:String; The function name of the ODT service from the Connect Request. The FunctionName is always COPYWRITESERVICES. It is defined in the Registry HKEY_LOCAL_MACHINE/ SOFTWARE/ Metalogic/ CopyWrite/ ServiceMapping. Spout("FunctionName is " & FunctionName)
FunctionName is COPYWRITESERVICES
Title:String; The Title when LibAccess = BYTITLE. Empty for the ODT Service.
Parameter:String; The Parameter field from the Connect Request. Empty for the ODT service.
HostName:String; The HOSTNAME of the A-Series Host which sent the ODT command. Spout("Originating Host is " & HostName)
Originating Host is RIBBONGUM
LibAccess:Integer; The LIBACCESS attribute which specified how to link to the ODT service. The LIBACCESS is always BYFUNCTION for the ODT service.

 

The Script Editor

The Script Editor is a basic tool which can be used to create ODT command scripts.

It is started from the Start | Programs | Metalogic | CopyWrite | ODT | Script Editor menu.

The program creates the Scripting Host and then fabricates a MESSAGE FROM CONTROLLER RESULT, which it uses to create the Script, TD830 and Intercom objects.

Hence, the Properties above are available for testing.