(SAT) Demo Application - deletehost |
Source Code |
#!/usr/bin/ksh #====================# # SCRIPT: deletehost # #====================# { mysql -v -v demo 2>&1 << !SQL delete from host where host = '${4}'; select 'satmysql no-fail silent'; delete from disk where host = '${4}'; !SQL } | satmysql Host && echo "action {main}"
Comments |
This script deletes a host and its associated disks. If the action is successful the list of hosts is displayed.
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 host where host = '${4}';The appropriate host entry is deleted from the demo database.
select 'satmysql no-fail silent';When the disk information is deleted from the demo database no messages are to be generated (silent). As it is possible that there are no disks for the host, the satmysql command is set to delete the disks without failing (no-fail).
delete from disk where host = '${4}';The appropriate disk entries are deleted from the demo 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 delete satement is unable to delete the host, satmysql will generate an "Unable to Delete Host" message. If the delete is successful, the main (Hosts) screen is displayed.