tclObjSrv(3Tcl) tclObjSrv(3Tcl)
tclObjSrv - Tcl-library interface to the object server
libtclObjSrv.so
libtclObjSrv.so is a Tcl shared library with extensions for accessing the
object server. It supports the get, set, create, remove, verify, search
and DSsearch operations, as well as an info pseudo-op that returns
information about the database.
For each object class there is a command defined; the command name is the
class name prefixed by a dot (.) character. The first parameter to the
object commands is an option, one of: get, set, create, remove, verify,
search, DSsearch, or info. For example, the following command
sgitcl>.hostObject info
will execute the info option for the hostObject class. The object name
may be abbreviated to the least unambiguous string. The options are
described in detail below.
Opening the library
To open the library, execute the following command from within sgitcl:
sgitcl>dlopen libtclObjSrv.so init ObjSrv_Init
The target server will default to the login host. The IP address of the
target is available in the Tcl variable "_objAddr". To change targets,
set this variable to the IP address of the desired server. For example,
sgitcl> set _objAddr 192.26.75.54
192.26.75.54
will target object operations at the specified machine (the set command
will print the new value of the variable). There is also a command
called gethostbyname that will do an IP lookup on a server name; so the
above command could be executed as:
sgitcl> set _objAddr [gethostbyname alpine]
192.26.75.54
The brackets tell Tcl to execute the contents as a separate command and
substitute the result string for the bracketed text.
Page 1
tclObjSrv(3Tcl) tclObjSrv(3Tcl)
Command Syntax
sgitcl>.objectName get oid attributes
The get option retrieves attributes of an object instance, specified
by oid. The attributes to be retrieved are defined by a list of
aid's; attribute names may also be used (derived attributes are
recognized). The list must be enclosed in quotes "" or braces {} if
it contains more than one element. The returned string will contain
the values formatted as a list in the order specified on the
command.
Example:
sgitcl> .hostObject get 59.201.1762020729.1 {59.201.1 owner}
alpine rj
sgitcl>.objectName set oid aid-value-list
The set option sets the values of attributes of an object instance,
specified by oid . The aid-value-list parameter is a list of
aid/value pairs defining the attributes to be set. The return value
is an empty string.
Example:
sgitcl>.hostObject set 59.201.1762020729.1 {owner Beavis}
sgitcl>.hostObject get 59.201.1762020729.1 {owner}
Beavis
sgitcl>.objectName create aid-value-list
The create option makes a new instance of the class. The aid-
value-list is a list of aid/value pairs defining the attributes of
the object; any requiredOnCreate attributes must be defined. The
return value is the oid of the new instance.
Example:
sgitcl>set beavisOID [.peopleNISObject create \
=> {loginName beavis jobTitle "MTV flunky"}]
sgitcl>.peopleNISObject get $beavisOID jobTitle
MTV flunky
Note the use of Tcl's set command to store the returned oid in a
variable, which can then be used to perform further operations on
the new object.
sgitcl>.objectName remove oid
The remove option destroys an instance of the class, specified by
oid. The return value is an empty string.
Page 2
tclObjSrv(3Tcl) tclObjSrv(3Tcl)
Example:
sgitcl>.peopleNISObject remove $beavisOID
sgitcl>.peopleNISObject get $beavisOID loginName
query error (1)
Note that after the object is removed, an attempt to access that
object results in LEGO error 1 (LEGO_ERR_NoSuchName).
sgitcl>.objectName verify
Performs the verify operation on the target server. Returns an
empty string. In this case, the object name is not significant
(i.e. any class may be used).
Example:
sgitcl>.host verify
sgitcl>.objectName search attr-value-op-list
Performs a search on the target server. The attr-value-op-list is a
list of attribute/value comparisons defining the filter to be
applied to the object database. Each comparison consists of an aid
(or attribute name), a comparison operator, and a value. The return
value is a list of matching oid's.
Example:
sgitcl>.host search {systemName=alpine owner = rj}
59.201.1762020729.1
Note that spaces are optional around the operator; if the value
string is a list, or contains embedded whitespace, it must be
enclosed in quotes or braces, and must be preceded by a space
(before the open quote or brace). The comparison operators are
defined as for C/C++:
= exactly equal
!= not equal
>= greater than or equal
<= less than or equal
> strictly greater
< strictly less
Integer values are translated in hex if preceded by 0x, and in octal
if a leading zero (i.e. C style translation). Boolean values may be
specified as "true" or "false". An attribute of type legoTypeTime
is translated using the getdate() routine. Strings with embedded
spaces must be enclosed in quotes or braces.
Page 3
tclObjSrv(3Tcl) tclObjSrv(3Tcl)
The "matches any" operator is not defined; simply leaving the
attribute out of the filter will achieve the same effect.
sgitcl>.objectName DSsearch attr-value-op-list important-attrs [-any]
Performs a Directory Server search. The attr-value-op-list is as
for search. The important-attrs argument is a list of
aid's/attribute names to be returned. The optional switch -any
indicates that any server may respond; if omitted, then the search
is directed at the current target server. The return value is a
list of oid/attribute-list pairs, one for each matching object
found. After this command returns, the global variable
"_objResponder" will contain the IP address of the server that
responded.
Example:
sgitcl>set _objResponder
can't read "_objResponder": no such variable
sgitcl>.host DSsearch {systemName=alpine} {numCPUs memSize} -any
59.201.1762020729.1 {1 41943040}
sgitcl>set _objResponder
192.26.75.11
sgitcl>.objectName info [option [args]]
Provides information about the object database. With no option
parameter, the info command will return the complete description of
the object as it appears in the *.op file used to initialize the
database. The other options are described below:
sgitcl>.objectName info anames
Returns a list of the attribute names defined for the object;
derived attributes are NOT included.
sgitcl>.objectName info oid
Returns the class oid (with the system and instance fields set to
zero).
sgitcl>.objectName info aid attr-name
Returns the aid of the named attribute.
sgitcl>.objectName info attr attr-name
Returns the text description of an attribute as it appears in the
*.op file.
Page 4
tclObjSrv(3Tcl) tclObjSrv(3Tcl)
sgitcl>.objectName info parent
Returns the name of the base class. For the baseObject class, the
returned value is an empty string.
Tcl(3Tcl)
PPPPaaaaggggeeee 5555 [ Back ]
|