(SAT) Demo Application - deletedisk |
Source Code |
#!/usr/bin/ksh #====================# # SCRIPT: deletedisk # #====================# { mysql -v -v demo 2>&1 << !SQL delete from disk where host = '${4}' and disk\$id = '${5}'; select 'satmysql force no-fail silent disk'; select disk\$id,disk\$size,type from disk where host='${4}'; !SQL } | satmysql Disk && echo "setMessage {\"Disk Deleted\"}"
Comments |
This script deletes a disk entry from the mysql demo database. The disk entries for the host are then selected to update the display.
Called by: displayhost
{ mysql -v -v demo 2>&1 << !SQLThe 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.
delete from disk where host = '${4}' and disk\$id = '${5}';The appropriate disk entry is deleted from the demo database.
select 'satmysql force 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 also forces satmysql to produce and empty result (force) 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 Disk && echo "setMessage {\"Disk Deleted\"}"The output from the mysql command is piped to satmysql. If the delete is successful a "Disk Deleted" message is displayed. Any error messages generated by the SQL will be trapped and labeled with Disk. For example: If the delete satement is unable to delete the disk, satmysql will generate an "Unable to Delete Disk" message.