(SAT) Demo Application - inserthost

Source Code

#!/usr/bin/ksh
#====================#
# SCRIPT: inserthost #
#====================#

{ mysql -v -v demo 2>&1 << !SQL
insert into host
   (host,serial_no,company,model,os,processors,speed_mhz,memory_mb,ip_address,updated)
   values('${4}','${5}','${6}','${7}','${8}','${9}','${10}','${11}','${12}',1);
!SQL
} | satmysql Host && echo "action {displayhost ${4}}"
Comments

This script inserts a new host entry into the demo database.

Called by: 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.
insert into host
   (host,serial_no,company,model,os,processors,speed_mhz,memory_mb,ip_address,updated)
   values('${4}','${5}','${6}','${7}','${8}','${9}','${10}','${11}','${12}',1);
The host entry is inserted into the demo database. The updated field is initialised to 1, which is expalined in updatehost.
!SQL
} | satmysql Host && echo "action {displayhost ${4}}"
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 insert satement is unable to insert the host, satmysql will generate an "Unable to Insert Host" message. If the insert is successful the displayhost (Host) screen is displayed.


Copyright © 2000 Adrian Davis.