#!/usr/bin/ksh
#====================#
# SCRIPT: insertdisk #
#====================#
{ mysql -v -v demo 2>&1 << !SQL
insert into disk
(host,disk\$id,disk\$size,type)
values('${4}','${5}','${6}','${7}');
select 'satmysql silent-ok disk';
select disk\$id,disk\$size,type
from disk
where host='${4}';
!SQL
} | satmysql Disk && echo "setMessage {\"Disk Inserted\"}"
This script inserts a new disk entry into the demo database. The disk entries for
the host are then selected to update the display.
Called by:displayhost
{ 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.
insert into disk
(host,disk\$id,disk\$size,type)
values('${4}','${5}','${6}','${7}');
The disk entry is inserted into the demo database. 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.
select 'satmysql silent-ok 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
if the select succeeds (silent-ok).
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 Disk && echo "setMessage {\"Disk Inserted\"}"
The output from the mysql command is piped to satmysql. If the
insert is successful a "Disk Inserted" message is displayed. Any error messages
generated by the SQL will be trapped and labeled with Disk. For example:
If the insert satement is unable to insert the disk, satmysql will generate
an "Unable to Insert Disk" message.
Copyright © 2003 Adrian Davis.