HP-UX CMGR A.02.01 Administrator's and Developer's Guide

38
sub check_system
{
my ($name, $value, $errMsg) = @_;
# detaint
$value=~/^(.*)$/; $value=$1;
# make sure a nodename was specified
$errMsg="Error: invalid hostname for $name" if !$errMsg;
die $errMsg if !$value || $value!~/^\w+$/;
# check if the node is reachable
my $out=`/usr/sbin/ping $value -n 1 2>&1`;
die "Error: $value is not reachable.\n" if $?;
}
Run the cmgr command with the custom.cst template:
% cmgr -t custom.cst -a
Enter the requested values when prompted, then press return.
Enter "?" for help at prompt. Press control-c to exit.
Client system name: xxxyyyzzz
---------------------------------------------------------------
Error: xxxyyyzzz is not reachable.
Enter "?" for help at prompt. Press control-c to exit.
---------------------------------------------------------------
Client system name: system4
Tag identifier: [] test tag string
The following template variables have been set to the values shown:
system_name = system4
tagid = test tag string
Press return or enter "yes" to make the selected modifications with these
values. Do you wish to continue? [yes]
%
% cmgr -t custom.cst -l -v
client=system1 # t1
client=system2 # t1
client=system3 # t2
client=system4 # test tag string
%
% cmgr -t custom.cst -d tagid=t1
% cmgr -t custom.cst -l -v
client=system3 # t2
client=system4 # test tag string
%