(SAT) Demo Application - printhost

Source Code

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

{ mysql -v -v demo 2>&1 << !SQL
select 'satmysql print continue';
select  *
  from  host
  where host='${4}';
select 'satmysql print disk';
select  disk\$id,disk\$size,type
  from  disk
  where host='${4}';
!SQL
} | satmysql | satform host | lp -d${3} -onobanner -s
echo "setMessage {\"Print Request Issued\"}"
Comments

This script prints the details of the specified host.

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.
select 'satmysql print continue';
When the host details are selected they are to be formatted for printing by satform (print). The details to be printed will be continued by subsequent SQL statements (continue).
select  *
  from  host
  where host='${4}';
The details for the appropriate host are selected.
select 'satmysql print disk';
When the disk details are selected they are to be formatted for printing by satform (print). Each disk entry will be prefixed with disk and appended to the host details selected previously.
select  disk\$id,disk\$size,type
  from  disk
  where host='${4}';
The disk information for the host is selected and added to the print request data. 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 | satform host | lp -d${3} -onobanner -s
The output from the mysql command is piped to satmysql (Any error messages are suppressed when the print option is used). The output from satmysql is piped to satform, where it is merged with the host form. The final merged form is piped to lp. Parameter ${3} is the printer assigned in the users file. The -onobanner option is used to suppress the banner page. The -s flag is used to suppress the notification of the print request ID (This may depend on the Unix variant in use).

NOTE: All standard output from a process is assumed to be SAT/DL commands. Anything else will cause a runtime error in the SATGUI client.

echo "setMessage {\"Print Request Issued\"}"
Display a message confirming that the print request has been issued.


Copyright © 2000 Adrian Davis.