We no longer offer ftp downloads. If there is a file you need referenced here, please contact me by email and I will get it to you.
Bruce Baumann offers this script as an example of controlling print jobs from RealWorld or other similar applications that allow you to specify a program to be used for printing. This script can be easily extended to do other functions.
Download rwprint.
# #################################### # # # RealWorld printer output muncher # # # #################################### # # WARNING: # If you can not read gawk script and / or do not know how to setup # RealWorld start up files then find someone who can do this for you # *** OR YOU COULD TRASH YOUR WHOLE REALWORLD SYSTEM AND OTHER STUFF *** # .... Ha Ha Ha Ha Harrrr ... # # NOTE: # This has only been tested with... # - GNU gawk V3 (From the Skunkware distribution CD-ROM) # - Australian Modified RealWorld V7 # - SCO OpenServer 5.0.x # It could work with the DOS version of gawk and you will need to change # the file pathnames accordingly ... Have a Go !!! # # To be configured as a print command in the RealWorld startup file. # # DD_PRINTER1=">[Path to gawk] -f [Path to this file] -v type=[Type of filter] -v printer=[name of printer]" # export DD_PRINTER1 # # DD_QC_PRINTER1=">/u/qc/bin/gawk -f /u/qc/bin/qc.gwk -v type=print -v printer=laserjet_1" # export DD_PRINTER1 # # For each type of filter define a function and trigger it from a # main selection block. This will make the list of filters easier # to find. # ################### # # # Start Functions # # # ################### # # rwPrint -- # # Send contents of a file to a printer # function rwPrint(PRINTER,DATAFILE) { if (PRINTER == "laserjet_1") {system("lpr -s -Tl -d laserjet_1 " DATAFILE)} if (PRINTER == "laserjet_2") {system("lpr -s -Tl -d laserjet_2 " DATAFILE)} } # # rwLogPrint -- # # Capture a standard print job, send it to file with date and user name # then print the file. # function rwLogPrint() { # PATH="/u/qc/print" PATH="/tmp" NAME="rw.print." DATE "." USER ".dat" DATAFILE=PATH "/" NAME while (getline LINE > 0) { print LINE > DATAFILE } close(DATAFILE) rwPrint(PRINTER,DATAFILE) } # # rwHtml -- # # Capture a standard print job, send it to a file in a users home directory as html # (Remove some printer codes and wrap it <PRE> tags ... :-) # function rwHtml() { RS="014" FS="\n" # PATH=USERHOME PATH="/tmp" NAME="rw." USER ".html" DATAFILE=PATH "/" NAME print "<HTML><BODY TEXT=black BGCOLOR=white><B><PRE>" > DATAFILE while (getline LINE > 0) { gsub("\000","",LINE) gsub("\014","",LINE) gsub("\015","",LINE) print LINE >> DATAFILE } print "</PRE></B></BODY></HTML>" >> DATAFILE close(DATAFILE) } # # rwStatementV3 -- # # RealWorld A/R Statements # - AR statement format 3 # # Capture a statement print job, send it to file with date and user name # Send contents of a file to a printer # function rwStatementV3() { # PATH="/u/qc/statements" PATH="/tmp" NAME="rw.stmt." DATE "." USER ".dat" DATAFILE=PATH "/" NAME printf ("") > DATAFILE lineCount=0 while (getline LINE > 0) { lineCount++ if (lineCount == 51) {printf ("\014", LINE) >> DATAFILE ; lineCount=0} else {printf ("%s\n", LINE) >> DATAFILE} } close(DATAFILE) rwPrint(PRINTER,DATAFILE) } # # rwChequeRemitV4 -- # # RealWorld A/P Checks and Remittances # - Cheque format 4 # - Print company name on BOTH # - Print cheque number on BOTH # # Capture a Cheque Remittance print job # Add in printer form feeds for each Cheque / Remittance and a Heading # Send it to file with date and user name # Send contents of a file to a printer # function rwChequeRemitV4() { # PATH="/u/qc/chkremit" PATH="/tmp" NAME="rw.chkremit." DATE "." USER ".dat" DATAFILE=PATH "/" NAME printf ("") > DATAFILE lineCount=0 while (getline LINE > 0) { if ((LINE ~ / [0-9][0-9][0-9][0-9][0-9][0-9]\015$/) && (lineCount == 0)) { # # If this is the first line of the print job the data should be as above. # Just print the data and the Remittance heading. # printf ("Cheque and Remittance...\n\n%s\n", LINE) > DATAFILE } else if ((LINE ~ / [0-9][0-9][0-9][0-9][0-9][0-9]\015$/) && (lineCount > 0)) { # # If this is the first page or any other page of the print job the data # should be 6 CR's plus the remittance data. # Print the data for this page and the Remittance heading for the next page. # printf ("\014Cheque and Remittance...\n\n%s\n", LINE) > DATAFILE } else { # # Just print page data # printf ("%s\n", LINE) > DATAFILE } lineCount++ } close(DATAFILE) rwPrint(PRINTER,DATAFILE) } # # rwRemitV4 -- # # RealWorld A/P Checks # - Cheque format 4 # - Print company name on BOTH # - Print cheque number on BOTH # # Capture a Cheque print job # Add in printer form feeds for each Remit and a Heading # Send it to file with date and user name # Send contents of a file to a printer # function rwRemitV4() { # PATH="/u/qc/remit" PATH="/tmp" NAME="rw.remit." DATE "." USER ".dat" DATAFILE=PATH "/" NAME printf ("") > DATAFILE lineCount=0 while (getline LINE > 0) { x="\015\015\015\015\015\015" if (LINE == x && lineCount == 0) { # # If this is the first line of the print job the data should be 6 CR's. # Just print the data and the Remittance heading. # printf ("%sRemittance...\n", LINE) > DATAFILE } else if (LINE == x && lineCount > 0) { # # If this is the first page or any other page of the print job the data # should be 6 CR's plus the remittance data. # Print the data for this page and the Remittance heading for the next page. # printf ("\014%sRemittance...\n", LINE) > DATAFILE } else { # # Just print page data # printf ("%s\n", LINE) > DATAFILE } lineCount++ } close(DATAFILE) rwPrint(PRINTER,DATAFILE) } # ################## # # # Start Program # # # ################## # # Do everything in the BEGIN statement # BEGIN { RS="\n" FS="\t" # # Setup some common variables # TYPE=type # PRINTER=printer PRINTER="xyz" DATE=strftime("%Y%m%d%H%M%S") USER=tolower(ENVIRON["LOGNAME"]) USERHOME=USER "/" home # # MAIN FILTER LIST # # For filter descriptions, see the function headers. # if (TYPE == "print") {rwLogPrint()} if (TYPE == "html") {rwHtml()} if (TYPE == "statement") {rwStatementV3()} if (TYPE == "chkremit") {rwChequeRemitV4()} if (TYPE == "remit") {rwRemitV4()} }
Publish your articles, comments, book reviews or opinions here!
© August 2001 Bruce Baumann. All rights reservedGot something to add? Send me email.
More Articles by Bruce Baumann © 2009-11-07 Bruce Baumann
A man can be destroyed but not defeated. (Ernest Hemingway)
Printer Friendly Version
Real World Printer script Copyright © August 2001 Bruce Baumann
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version