OK, resurrecting a dead thread, but here is one solution that can be used to generate Excel, HTML, PDF or whatever kind of file you want from Unix Character MFG/PRO. This is a long post and I have not attached any programs or scripts, but you should be able to see the method.
This is quite a long post. I have copied and pasted program chunks and parts of scripts, so it might have some typos in, but hopefully it should work. If there are typos/bugs in the scripts/programs then please let me know.
What you need are several shell scripts that allow data to be piped in, then you can set up MFG/PRO Printers that use these scripts.
So, you could have the following scripts:
/usr/bin/qad/prn2csv.sh
/usr/bin/qad/prn2html.sh
/usr/bin/qad/prn2xls.sh
/usr/bin/qad/prn2pdf.sh
/usr/bin/qad/prn2dummy.sh
You set up new MFG Printers with the command line "cat | /usr/bin/qad/prn2xls.sh"
Each script uses a common script in the same way as Progress uses include files to make certain functions available in the script. The scripts then call f_stdin2file and tell it the extension of the temporary file, extension of the output file and the program to be used to generate the file.
The programs used to generate the output are of the form:
prn2csv.p
prn2xls.p
prn2html.p
prn2pdf.p
prn2dummy.p
and will have to be written in-house. However, they share common functionality which is defined in an include file.
The include file prn2.i extracts the Input Filename and Output Filename from the SESSION
ARAMETER, check to see if the input file exists (it is created by the calling script so it should always exist) and then reads each line at a time, adding each line to a temp-table.
Each program then processes the temp-table accordingly.
You can easily set up as many different scripts as you want, depending on what kind of output you need.
The scripts themselves are of the form:
/usr/bin/qad/prn2xls.sh:
Code:
. /usr/bin/qad/prn2.sh
f_stdin2file "tmp" "xls" "$PRN2DIR/sh/prn2xls.p"
/usr/bin/qad/prn2pdf.sh:
Code:
. /usr/bin/qad/prn2.sh
f_stdin2file "tmp" "pdf" "$PRN2DIR/sh/prn2pdf.p"
/usr/bin/qad/prn2htm.sh:
Code:
. /usr/bin/qad/prn2.sh
f_stdin2file "tmp" "htm" "$PRN2DIR/sh/prn2htm.p"
/usr/bin/qad/prn2dummy.sh:
Code:
. /usr/bin/qad/prn2.sh
f_stdin2file "tmp" "txt" "$PRN2DIR/sh/prn2dummy.p"
/usr/bin/qad/prn2.sh:
Code:
PRN2DIR=/home/prn2
PRN2LOGDIR=$PRN2DIR/log
SCRIPTS=/usr/bin/qad
PROGEXE=$DLC/bin/mpro
PROGPF=" "
PROGSTARTPROG="-p $PRN2DIR/sh/run.p"
f_prorun ()
{
cd $SCRIPTS/work
$PROGEXE $1 $PROGPF $PROGSTARTPROG -param "$2,$3,$4,$5,$6,$7,$8" 1>/dev/null 2>&1
}
f_batchrun ()
{
f_prorun "-b" "$1" "$2" "$3" "$4" "$5" "$6" "$7"
}
f_stdin2file ()
{
TMPROOT=`f_gettmp `
cat > $TMPROOT.$1 ; f_batchrun "$3" "$TMPROOT.$1" "$TMPROOT.$2" ; rm $TMPROOT.$1
}
f_getcount ()
{
COUNTFILE="$PRN2DIR/count/$1.count"
if [ ! -e $COUNTFILE ]
then
echo 0 > $COUNTFILE
fi
TMPCOUNT=`cat $COUNTFILE`
TMPCOUNT=`expr $TMPCOUNT + 1`
echo $TMPCOUNT > $COUNTFILE
echo $TMPCOUNT
}
f_gettmp ()
{
echo $PRN2DIR/tmp/tempfile_` whoami `_`f_getcount gettmp `
}
export PRN2DIR PRN2LOGDIR SCRIPTS
/home/prn2/sh/run.p:
Code:
define variable cProgram as char no-undo.
assign cProgram = search(entry (1,session:parameter)).
if cProgram <> ? then run value (cProgram).
QUIT.
/home/prn2/sh/prn2.i:
Code:
def var cInputFilename as char no-undo.
def var cOutputFilename as char no-undo.
def var cline as char no-undo.
def var clog as char no-undo.
def temp-table ttline no-undo
field tcount as int
field tline as char
index idx1 is primary tcount.
def var icount as int no-undo.
def stream sIn.
def stream sOut.
run ipGetFilenames.
procedure ipGetFilenames:
if num-entries (session:parameter) >= 2 then
cInputFilename = entry (2,session:parameter).
if num-entries (session:parameter) >= 3 then
cOutputFilename = entry (3,session:parameter).
if search (cInputFilename) = ? then return.
run ip_import_prn_file.
end procedure.
procedure ip_import_prn_file:
input stream sIn from value (cInputFilename).
repeat:
cline = "".
import stream sIn unformatted cline.
icount = icount + 1.
create ttline.
ttline.tline = cline.
end.
output stream sIn close.
end procedure.
/home/prn2/sh/prn2xls.p:
Code:
{/home/prn2/sh/prn2.i}
run ipProduceXlsFile.
/home/prn2/sh/prn2pdf.p:
Code:
{/home/prn2/sh/prn2.i}
run ipProducePDFFile.
/home/prn2/sh/prn2dummy.p:
Code:
{/home/prn2/sh/prn2.i}
run ipProduceDummyFile.
procedure ipProduceDummyFile:
output stream sOut to value (cOutputFilename).
for each ttline use-index idx1:
put stream sOut unformatted "NOW:" ttline.tline skip.
end.
input stream sOut close.
end procedure.