Re: Print wide mode
Posted in 1992
Here is a script that, when piped to, will give a choice of options e.g. No Code Action ============================================== 1) S Display to the screen - 80 columns. 2) SW Display to the screen - 132 columns. 3) P Print - 80 column mode. 4) PW Print - 132 column mode. 5) F Save to a file. 0) Q Quit. ---------------------------------------------- Please enter a item number or code. ---------------------------------------------- #---------------qpr_rpt.sh---------------------------------- # # The intent of this script is to be used as a "pipe" for informix. This # script drives qpr_rpt from the ksh shell since informix uses the sh shell. # /bin/ksh -c /usr/bin/qpr_rpt ---------------------------end--------------------------- #---------------- qpr_rpt ------------------------------ # NOTE! # Make sure that IN_TERM is defined and exported in your .profile # file. # # Example of output statement: # output # report to pipe "qpr_rpt.sh" # end # # example: # IN_TERM=`tty`; export IN_TERM # If you want to define a default print queue, define DEF_QUEUE in your # .profile file. # example: # DEF_QUEUE="text"; export DEF_QUEUE #---------------------------------------------------------------------- BOLD="\\033[1m" NORM="\\033[0m" BEEP="\\007" NORMAL="\\033[?3l" WIDE="\\033[?3h" TEMP_FILE="/usr/tmp/$$pr" NEXT_CHOICE="S" # # F u n c t i o n s # display_80() { echo "${NORMAL}" pg ${TEMP_FILE} return 0 } display_132() { echo "${WIDE}" pg ${TEMP_FILE} return 0 } which_queue() { echo "Queue> [${DEF_QUEUE}] \\c" read QUEUE < ${IN_TERM} : ${QUEUE:=${DEF_QUEUE}} [ ${QUEUE} ] || \\ { echo "${BEEP}Error, no queue defined..." return 1 } return 0 } print_it() { which_queue [ $? -ne 0 ] && return 1 qpr -q $QUEUE -t $1 ${TEMP_FILE} return 0 } save_rpt() { DEF_FILE="${HOME}/report.`date '+%H%M%S'`" echo "Filename> [${DEF_FILE}] \\c" read FILENAME < ${IN_TERM} : ${FILENAME:=${DEF_FILE}} cd ${HOME} if [ -f ${FILENAME} ] then echo "${FILENAME} already exists, overwrite? [n] \\c" read answer < ${IN_TERM} : ${answer:=n} case "${answer}" in N*|n*) echo "${BEEP}File not saved." return 0 ;; *) ;; esac fi cp ${TEMP_FILE} ${FILENAME} [ $? -ne 0 ] && \\ { echo "${BEEP}Error, could not create ${FILENAME}..." return 1 } echo "Report saved to ${FILENAME}" return 0 } # # Make sure that IN_TERM is defined # [ "${IN_TERM}" ] || \\ { echo " $0:${BEEP} \\tIN_TERM undefined... \\tinclude the following in your .profile: \\t\\tIN_TERM=\\`tty\\`; export IN_TERM " exit 1 } # # Create the temporary file # pr -t > ${TEMP_FILE} # # Display the menu # while true do echo "${NORMAL} What do you want to do with the report? No Code Action ============================================== 1) S Display to the screen - 80 columns. 2) SW Display to the screen - 132 columns. 3) P Print - 80 column mode. 4) PW Print - 132 column mode. 5) F Save to a file. 0) Q Quit. ---------------------------------------------- Please enter a item number or code. ---------------------------------------------- Choice? [${NEXT_CHOICE}] \\c" read choice < $IN_TERM : ${choice:=${NEXT_CHOICE}} case "${choice}" in 1|S|s) display_80 NEXT_CHOICE="P" ;; 2|SW|sw) display_132 NEXT_CHOICE="PW" ;; 3|P|p) print_it text NEXT_CHOICE="Q" ;; 4|PW|pw) print_it ctext NEXT_CHOICE="Q" ;; 5|F|f) save_rpt NEXT_CHOICE="Q" ;; 0|Q|q) break ;; *) echo "Not a valid choice, Please pick one of the listed choices." ;; esac done exit -- Best Regards, * * * _______________________________________________________________________ Thomas Hereford | Internet: herefota@ingr.ingr.com | Here Comes the Sys Admin | UUCP : uunet!ingr!herefota | Sun, and I say, Intergraph Corp | FAXmodem: (313)351-3278 | Its Alright... Detroit, Mi | Voice : (313)351-6826 | _Beatles _____________________________________________________ "If we get an inquiry from someone who is naive, and we respond with ridicule, we are more likely to cause that person to stop asking questions rather than impart educational information." Ed L'Esperance _______________________________________________________________________