PreviousNext

Manipulating Data in Other Host Files

While the hostdata object is useful for changing cell name and cell alias information, it has a broader use too; you can use it to add, change, and remove data from any file that is accessible on a DCE host.

One useful example is adding a new CDS attribute. Every DCE host has it's own CDS attributes file (cds_attributes) where it stores object id's for each CDS attribute. You could use the local host's editor to add the attribute and then copy the new file to each host. But this method requires you to log in to each host. A simpler method could use the hostdata object to add the new attribute to the CDS_attributes file. Place the operation within a foreach loop that re-executes it for each host in the cell.

1. Make the CDS attributes file accessible as an object of the hostdata object. First, use the hostdata object to create a CDS entry representing the CDS attributes file. Set the storage attribute to be the host filename of the CDS attributes file The following example assumes the CDS attributes file is in the default location.

dcecp> hostdata create /.:/hosts/silver/config/hostdata/cds_attr \

Ø -storage /opt/dcelocal/etc/cds_attributes -entry

dcecp>

2. The hostdata object modifies data in files by replacing all the data in the file with new data that you specify. The following example shows one way to do this. First, retrieve and store all the lines as dcecp list elements in a variable. Then create a new variable using the attrlist command to add the new line as a list element to the variable. Finally, copy the new variable back to the file.

dcecp> set val [attrlist getvalues [hostdata show \
> /.:/hosts/silver/config/hostdata/cds_attr]

dcecp> set newval [attrlist add $val -member {NEW_ATTR 1.2.3.4}]

dcecp> hostdata modify /.:/hosts/silver/config/hostdata/cds_attr -data $newval

dcecp>