#!/usr/bin/ksh
#=====================#
# SCRIPT: displayhost #
#=====================#
{ mysql -v -v demo 2>&1 << !SQL
select 'satmysql silent';
select *
from host
where host='${4}';
select 'satmysql no-fail silent disk';
select disk\$id,disk\$size,type
from disk
where host='${4}';
!SQL
} | satmysql Host || echo "action {main}"
This script selects host/disk details for display.
Called by: main, addhost
{ mysql -v -v demo 2>&1 << !SQL
The mysql command is used to access the demo database. The verbosity of
mysql is set to -v -v. All output is directed to standard output
so that it will be seen by satmysql. SQL satements are read until !SQL.
select 'satmysql silent';
When the host details are selected no messages are to be generated (silent).
select *
from host
where host='${4}';
The details for the appropriate host are selected.
select 'satmysql no-fail silent disk';
When the disk information is selected from the demo database the result is to be
put into the disk multi-column list and no messages are to be generated
(silent). As it is possible that the result of the select will find no disks,
the satmysql command is set to select the disks without failing (no-fail).
select disk\$id,disk\$size,type
from disk
where host='${4}';
The disk information for the host is selected to update the disk multi-column
list. The "$" characters must be escaped to stop the shell seeing them as part of
variable names. In screen procedures the ":" character is used instead of "$". For
example: The screen item disk:id refers to the disk$id column in
the database.
!SQL
} | satmysql Host || echo "action {main}"
The output from the mysql command is piped to satmysql. Any
error messages generated by the SQL will be trapped and labeled with Host.
For example: If the select satement is unable to select the host, satmysql
will generate an "Unable to Select Host" message. If the select fails, the main
(Hosts) screen is displayed.
Copyright © 2003 Adrian Davis.