KB#00068-Alias to print to a file and printer simultaneously
Title:
Alias to print to a file and printer simultaneously
Description:
Method 1:
It'll take 2 different aliases.
The first is pretty standard:
alias P1 /dev/lp1 "Std Printer" cr,lock=/tmp/lp1.lck
The second:
alias P2 ">tee $FILE >/dev/lp1" "Std/split Printer" cr,lock=/tmp/lp1.lck,FILE=/tmp/default
In the second case the same lockfile is used to manage the printer access, and the output is saved in the file named in the MODE= in the open, or in the default file /tmp/default. To use this alias use:
OPEN(7,MODE="FILE=/tmp/myfile")"P2"
This method can also be done using only one ALIAS line
alias PDS "> tee -a DR/rlf_MyDiskFile$$ | lp -dlp0 > /dev/null 2>&1"
Method 2:
Under UNIX piping the data to a shell script may give more control and is done like this:
Setup your alias like:
alias LPF "|ptr_file" "Dual print & save in file" CR ...,lock=/tmp/LPF.lck
Then the script would be similar to the one below (a # means it's a comment line in the script):
# ptr_file - sample shell script to print to a file and printer pjw/ubb 5/7/96
#
# get PID of this task - use to name unique files. Use another method if you reboot often and # need to have # the files preserved long term.
PID=$$
# Dir to use to store files
DIR=/usr/bbx/ubb/
# printer id (use $1 if you want to pass a specific ptr)
LP=/dev/lp0
# file name
FILE="${DIR}printfile.${PID}"
# the below simply grabs any data piped to this script & writes it to the file.
cat >$FILE
# assumes locking is handled in config.bbx
cat $FILE>$LP
# end
Output to the printer won't start until you have closed the channel.
Last Modified: 06/08/2006 Product: PRO/5 Operating System: All platforms
BASIS structures five components of their technology into the BBx Generations.