ifhost hostname1 {commands} hostname2 {commands} {commands}
Conditionally execute commands that are specific to given cbicontrol hosts.
hostname
commands
ifhost
command in the cbicontrol initialization script to specify where
archive and log files should be created on a host-by-host basis.
ifhost snug { open archive, dir=/scr/mcs/arc open log, dir=/scr/mcs/log } lyra { open archive, dir=/scr2/mcs/arc open log, dir=/scr2/mcs/log } { print "Warning: I don't know where to put archive and log files on ", $hostname, ".\n" }
ifhost vega { gpib_send 15, "TR" }
ifhost
command is a preprocessing command. It
tells the compiler in cbicontrol to skip statements that are
marked as being specific to another computer. This allows one to
include statements that cite file-names that don't exist on every
computer on which cbicontrol can be run. These file-names would
otherwise cause cbicontrol to reject the containing script.
The ifhost
command works a bit like an
if-elseif-else type of statement. After the list of statements
that follows the first hostname, one can specify another hostname
and list of statements. This in turn can be followed by another
hostname and statement-list. Once a matching hostname is found,
the corresponding list of statements is compiled, and the rest of
the hostname/statement-list pairs are skipped. If none of the
hostnames match and the list of statements that follows the last
hostname is followed immediately by another list of statements
without an intervening hostname, then that final list of
statements is executed.
For example:
ifhost goblin { print "goblin" }
will not print anything unless cbicontrol is running on goblin. Similarly,
ifhost goblin { print "goblin" } elf { print "elf" }
will print "goblin" if cbicontrol is running on goblin, "elf" if it is running on elf, but nothing at all otherwise. Finally:
ifhost goblin { print "goblin" } elf { print "elf" } { print "Unexpected host: ", $hostname }
will print the same as the previous example, except in the case where cbicontrol is running on neither goblin nor elf. In this case it will print a warning message about the unknown host.