Printing to a file on WingZ
Posted in 1991
Path: emory!swrinde!sdd.hp.com!hplabs!hpfcso!hpcndm!joeg From: joeg@hpcndm.CND.HP.COM (Joe Grim) Newsgroups: comp.databases.informix Message-ID: <64070001@hpcndm.CND.HP.COM> Date: 20 Sep 91 16:21:05 GMT Organization: HP Colorado Networks Division I'm posting this very helpful note for Erik Sherk on how to print to a file in WingZ. +----------------------------------------------------------------+ | ************* | Joe Grim | | ***** ****** | Hewlett-Packard Company | | *** /_ _ *** | Colorado Networks Division | | ** / / /_/ ** | 3404 East Harmony Road | | *** / *** | Fort Collins Colorado USA 80525-9599 | | ***** ****** | E-mail: joeg@hpcndm.cnd.hp.com | | ************* | Telephone (303) 229-3910 FAX (303) 229-3526 | +----------------------------------------------------------------+ | The Cartesian view of networking - IP, therefore I am! | +----------------------------------------------------------------+ ============================================================================ Hello, A week or so I asked how one printed to a file from Wingz. I got one reply (sorry, I didn't save the mail)saying that you can't, but you could replace the lpr command with a script in printer.info to do what you want. He suggested flagging a special number of copies to mean print to a file i.e. printing 666 copies of a file means print to a file. Well I didn't want to have to explain that to my users, also I wanted to specify the name of the file to print to. So, I wrote a perl script to replace the lpr command in printer.info. To do this, just replace lpr with the name of the script (I call it Wingz.print). Also, define another printer in printer.info called file {to do this, specify two printers in the total printers line. Also, the second printer needs things like Total fonts and the font mappings.} Luckly, stdin and stdout are still attached to the window that you started Wingz from, so this script prompts you for the name of the output file in that window. Enjoy.... Erik Sherk sherk@nmc.cit.cornell.edu Cut here: -------8<-------8<-------8<-------8<-------8<-------8<-------8<--- #!/usr/local/bin/perl # # This perl script is called by Wingz when it wants to # print something instead of calling lpr. This is so we # can print to a file. This script looks for a "printer" # called "file". Else it sends it to lpr. # Erik Sherk 9/18/91 # sherk@nmc.cit.cornell.edu #some inits $printer = "-Plp"; $copies = "-#1"; $file = ""; # We are called like this: (read the args) # -Pprinter -#n /usr/tmp/WingzXXXX while ( $arg = shift( @ARGV )){ if ( $arg =~ /-P/ ){ $printer = $arg; next; } if ( $arg =~ /-\\#/ ){ $copies = $arg; next; } $file = $arg; } # at this point $printer and $copies are set # see if we want to print to a file if ( $printer =~ /file/ ){ # yes, get a file name from stdin print STDOUT "Enter file to print to:"; $newfile = <STDIN>; open (NEWFILE, ">$newfile") || die "Error opening $newfile $!\\n"; open (IN, $file) || die "Error Opening $file $!\\n"; # copy file while (<IN>) { print NEWFILE $_; } } else { # else send it to the printer.... system "/usr/ucb/lpr", $printer,$copies,$file ; } exit 0;