Administer a QICWARE system
- Introduction
- Adminisration script
- Simple PHP example
- Simple JDBC example
- Simple Mail and PDF Spooler example
Introduction
This document describes how to administer a QICWARE system. This information was written two decades ago. I hope someone finds it useful. If you do, please drop a comment. I’m also including a copy of the QICWARE handbook which was written about the same time. It provides an introduction to the Qantel QICWARE runtime system.
Adminisration script
Administration tasks are made easier with this administration script. Once this script is installed it can be updated by invoking the script with the updatescript option. This will cause the script to reload itself from this web site. To install the script, download it into the QICWARE Administrator’s home directory, grant it execute permission and run the installscript command. You can download the script by coping and pasting the following two lines into a text file, giving it execute permission and running it. The administration script is hosted on github.
wget https://raw.githubusercontent.com/patrick-melo/qw/main/qw
chmod u+x qw
`pwd`/qw installscript
Simple PHP example
PHP is an incredibly powerful programming language for creating web based applications. When coupled with QICWARE, applications become even more feature rich and powerful. This creates a QICWARE report using only a few lines of code. For details, refer to chapter 6 in the handbook. This demo uses the QICLOOK Demo Database.
Sample PHP output
STATUS STATUS_CODE
Active A
Leave (unpaid) L
Other O
Quit Q
Sick/Disabled S
Terminated T
Sample PHP source code
<html>
<head>
<title>PHP ODBC Example</title>
</head>
<?
putenv("OA_ROOT=/home/qicware/odbc");
putenv("LD_LIBRARY_PATH=/home/qicware/odbc/lib/ilinux");
putenv("ODBCINI=/home/qicware/odbc/config/ilinux/odbc.ini");
putenv("OPENRDA_INI=/home/qicware/odbc/config/ilinux/openrda.ini");
$conn = odbc_connect("qcd", "qsql", "qsql");
($conn > 0) || die ("Unable to connect to database");
$sql="SELECT * from EMPLOYEE_STATUS;";
$recordset = odbc_exec($conn, $sql);
odbc_result_all($recordset);
odbc_close($conn);
?>
</html>
Simple JDBC example
At the Users Group Conference many years ago, I was asked if QICWARE ODBC could be used in a non-graphical environment. In the past, we have demonstrated the use of ODBC with ASP, PHP, and VB, and it may have become unclear exactly what role ODBC and SQL plays in the whole process.
The QICWARE SQL server provides a way for clients to connect to a QICWARE database. The ODBC client provides the component necessary on the client computer to talk to the SQL server. Sometimes, the ODBC client and the SQL server are located on the same computer; the user simply adds the QICWARE ODBC driver to the computer that runs QICWARE. In most cases, however, the driver is loaded on the computer that has Microsoft Word or Excel installed on it, because the ODBC driver will provide the means for these applications to connect to the SQL Server. The application itself can be written in any language. It can display the information however it chooses. The QICWARE ODBC driver actually comes with an application called “Interactive SQL (ODBC)”. This application is text based and can be run from a command prompt or by clicking on the icon in the Start menu.
With the release of version 1.4 of the Java platform, Sun provides developers with the ability to access ODBC data sources. These applications can be GUI or command-line based. This article contains an example of a simple command-based program. The program uses the QICLOOK demo database and requires that the data source name qcd be configured on the computer where the program is run. It was tested on Windows XP and Red Hat Linux 7.1.
To run the program, copy the code into a file named JDBCSample.java. To make sure the program will compile and run properly on your computer use the command java-version to verify that you have version 1.4 installed on your computer. Compile the program with javac JDBCSample.java and run it with java JDBCSample. Your output should look something like the output below.
Sample JDBC output
STATUS STATUS_CODE
Active A
Leave (unpaid) L
Other O
Quit Q
Sick/Disabled S
Terminated T
The source code hard-codes the login and password in the program. You may need to change this information so that it matches your system. With a few modifications the program could be designed to prompt the user for a password used in the connection to the QICWARE SQL Server.
Sample JDBC source code
import java.sql.*;
public class JDBCSample {
public static void main (String args[]) {
Connection conn = null;
final String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
final String url = "jdbc:odbc:qcd";
final String user = "qsql";
final String password = "qsql";
final String sql = "select * from EMPLOYEE_STATUS";
try {
Class.forName( driver ).newInstance();
conn = DriverManager.getConnection(url, user, password );
Statement select = conn.createStatement();
ResultSet result = select.executeQuery( sql );
System.out.println("STATUS\tSTATUS_CODE");
while( result.next() ) {
System.out.println(result.getString(1) + "\t" +
result.getString(2));
}
} catch(Exception e) {
System.out.println(e);
}
}
}
Simple Mail and PDF Spooler example
With QICWARE 6.60-D and above, QICWARE users have the ability to generate pdf’s and send email directly from the QICWARE system. This article will demonstrate the use of these two technologies combined to send a PDF as an attachment in an email. You will need to add two keywords into the m01.cfig, one for the SPOOL device and one for the EMAIL device. You will also need a compiler to compile the included source code. If you do not have a compiler, instructions on downloading and running an already compiled version of the program can be found on the QICWARE.COM web site.
Even if you do not wish to run the program, this article should give you some idea of how these new features can be used without any customized programs. *QICLOOK reports for example can be sent to the SPOOLER. The directory can then be published using a web server or using Microsoft File Sharing.
To begin, lets configure a SPOOL device. A pdf SPOOL device is very similar to the normal SPOOL device. The only real difference is that files sent to this device are stored in the PDF format instead of a plain sequential file. To configure a pdf SPOOL we add a SPOOL line, configure it the same way as a normal SPOOL and change the flag to ‘d’.
SPOOL = PDF, 52, none, spool, none, PDF, d
The EMAIL device uses a new keyword. Simply copy the following line into the QICWARE Configuration File.
EMAIL = EM1, E1, /usr/lib, qem, none, 1
Once you have modified the QICWARE Configuration file and restarted QICWARE, connect to QICWARE and make sure that both the SPOOLER and the EMAIL device are both available by going into *CONSOLE and doing a device status on the device.
SELECT OPTION: DS EM1
DEVICE STATUS FOR: 'EM1' - Generic Email
OWNING PARTITION:
SYSTEM STATUS: DEVICE IS AVAILABLE
SELECT OPTION: DS PDF
DEVICE STATUS FOR: 'PDF' - PDF Spooler
SPOOL OPTION: A,PDF
OWNING PARTITION:
SYSTEM STATUS: DEVICE IS AVAILABLE
Here is a sample program to create a PDF with the text ‘HELLO WORLD’. This text is sent to the spooler. We use the STS function to determine the name of the file that was created. We then use some email mnemonics to add the file as an attachment.
100 !S =SAMPLE,SYS
200 !O ?SAMPLE,SYS
300 !L TXX,E
400 !R *EDITX
500 !----------------------=o0-QICBASIC Source-0o=-----------------------
600 ! Title =SAMPLE
700 ! Description: Demonstration of SPOOL and EMAIL device.
800 ! Copyright: Qantel Technologies Inc.
900 !
1000 ! \|/
1100 ! POWERED BY (.~.)
1200 ! oO(_)Oo
1300 ! _ \ _ _| __|\ \ / \ _ \ ___|
1400 ! ( | | ( \ \ \ / _ \ / _|
1500 ! \__\_\___\___| \_/\_/_/ _\_|_\___|
1600 !
1700 ! ----------------------=o0-declarations-0o=------------------------
1800 LENGTH 1.0 & LOCAL CON
1900 LENGTH 1.0 & LOCAL ERR
2000 LENGTH 1.0 & LOCAL SPL
2100 LENGTH 1.0 & LOCAL EML
2200 LENGTH 37 & LOCAL STRERROR$
2300 LENGTH 17 & LOCAL STATUS$
2400 LENGTH 8 & LOCAL FILENAME$
2500 ! ------------------------=o0-formats-0o=---------------------------
2600 ERRMSG: FORMAT STRERROR$
2700 BANNER: FORMAT (ET)
2800 EMLFMT: FORMAT (ADDR="patrick@40@qantel.com");_
2900 (SUBJ="QICBASIC SAMPLE EMAIL");_
3000 (SFN=FILENAME$); (ATT=0); (EOF);_
3100 (FX)
3200 ! -------------------------=o0-main-0o=-----------------------------
3300 CON=0 & ERR=1 & SPL=2 & EML=3
3400 PRINT(CON, BANNER)
3500 OPEN (SPL) "PDF", EXCP=ERRSUB
3600 PRINT(CON) "OPENING SPOOL"
3700 PRINT(SPL) "HELLO WORLD", EXCP=ERRSUB
3800 STATUS$ = STS(SPL)
3900 FILENAME$ = SUB(STATUS$,6,8)
4000 CLOSE(SPL), EXCPSUB=ERRSUB
4100 OPEN (EML) "EM1", EXCP=ERRSUB
4200 PRINT(CON) "OPENING EMAIL TO SEND "; FILENAME$
4300 PRINT(EML,EMLFMT), EXCP=ERRSUB
4400 CLOSE(EML), EXCPSUB=ERRSUB
4500 PRINT(CON) "TRANSMIT TO CONTINUE"
4600 INPUT(CON) ""
4700 RUN "*MONITOR"
4800 ! ----------------------=o0-subroutines-0o=-------------------------
4900 ERRSUB:
5000 CLOSE(ERR) & OPEN(ERR) "*ERRFILE"
5100 EXAMINE(ERR,ERRMSG) IND="E"+STR(EXCP)
5200 PRINT(CON) " ** ERROR ("+STRIP(STR(EXCP))+") " + _
5300 STRERROR$
5400 INPUT(CON) ""
5500 RUN "*MONITOR"
5600 RETURN
Below is the output on the screen when the program is run. An email containing the attachment is sent to the address in the ADDR mnemonic.
OPENING SPOOL
OPENING EMAIL TO SEND #S326997
TRANSMIT TO CONTINUE
Comments
Join the discussion for this article on this ticket. Comments appear on this page instantly.