ecctp@warwick.ac.uk (Dr J A K Cave) (09/12/89)
The following documents a utility that I received as shareware. Although it bears a copyright notice, I believe it is available free. If this belief is mistaken, please notify me. I shall wait a week before posting the code (on c.b.i.p) to seek advice. LPT2DSK - Capture printer output to disk file. Version 1.0 October 3, 1986 (c) Copyright by George G. Bouche This program works by intercepting the printer bios interupt (17h) and capturing the would be printed data in a buffer which is later written to a disk file. By capturing at the bios level, all dos printing (file redirection, Ctl-PrtSc, LPT?, PRN, ...) and programs which call the bios directly (BASIC, Shft-PrtSc) are handled. Capturing is for a specific printer (LPT1, LPT2 or LPT3) and output to the other two printers is passed thru to the original INT17 interupt address. Usage: LPT2DSK [p] [nnK] [F=[d:][\path]filename[.ext]] p=1, 2 or 3 printer number for LPT1, LPT2, or LPT3 Default=1 LPT1 nn=1 to 64 the amount of memory (in multiples of 1024 bytes) to allocate to the printer buffer. The K is required. Default=64K filename any valid dos filename (can be a device) with optional drive, path and/or extension. The F= is required. Default=LPT2DSK.p where p=printer number as above on the current drive, current directory. Requirements: - Dos 2.0 or later. - The parameters can be in any sequence but must be delimited by space(s). - Any or all parameters can be ommitted. - The environment must have an entry for locating COMMAND.COM (COMSPEC= ) and COMMAND.COM must be available as it will be loaded. - LPT2DSK.EXE needs 9120 bytes + XXXX bytes for the resident portion of COMMAND.COM(for dos 3.1 this is 3200) + buffer size. - Multiple printers can be captured - just run the program again for the other printer. Remember, last one started is the first one to exit from. - Dos redirections of the printer (i.e. to COM?) are not detected and no data will reach the buffer. - The printer port hardware need not be present to capture data. The printer status of the captured printer is returned as ready/not busy unless the buffer has filled. Examples: LPT2DSK 2 32K F=CAPTURE.DAT capture LPT2 and reserve a 32k buffer. a secondary level of command.com is loaded. interupt 17h is replaced; no hardware or dos interupts are disturbed. ... run the programs that print and/or hit shift-print-screen and/or hit control-print-screen printing to LPT1 or LPT3 goes on un-affected if the buffer gets full, dos returns an "Not ready error writing device LPT2 Abort, Retry, or Ignore" the only option is to abort. EXIT exit secondary command.com and end LPT2DSK the file CAPTURE.DAT is opened and data is written. if the file existed before, it is overwritten. if no data was printed, the file will not be opened. interupt 17h is restored to value before capture. all allocated memory is returned - nothing resident. LPT2DSK F=LPT1 3 capture LPT3 and reserve a 64k buffer. the buffer will be written to printer 1 when done. Please direct any comments/suggestions/problems to: George G. Bouche P.O.Box 65111 Lubbock, TX 79464
ecctp@warwick.ac.uk (Dr J A K Cave) (09/12/89)
Code will be posted in a week if no copyright problems surface. Please advise. LPTx : Line Printer Output Capture Routine ------------------------------------------------------------------------ Version 6.00 (C) Copyright 1987 by Mark DiVecchio, All Rights Reserved This program is released for use in non-commercial environments. I ask commercial users to register the program with a $25 copyright fee for each site (any number of users and computers) at which the program is used. DISCLAMER : This program tries to perform a function which is not supported by DOS. It will work sometime and will not work other times. That kind of explains why you don't see this type of program on the market. I have tested it under DOS 2.x and 3.x. In particular, under 3.x, I used dBase-II. I have not tested it with dBase-III or dBase-III+. Mark C. DiVecchio 10435 Mountain Glen Terrace San Diego, CA 92131 619-566-6810 ------------------------------------------------------------------------ First - some thanks... I would like to thank all of the users who have called me about the earlier versions of LPTx which has been floating around for about a year. The program has met with mixed success. There seems to be no pattern as to when the program works and when it doesn't. I am still searching for the solution to this very difficult problem. This version and versions 4.x and 5.x which preceeded it are attempts to perform the same function with a different algorithm. Version 3.00, 4.00, 5.00 and 6.00 are not replacements or upgrades of each other but just alternative implementations. ------------------------------------------------------------------------ Have you ever wanted to get some data from your screen into a program? Have you ever wanted to grab onto some printer data and put it into a disk file but the program you are using does not have that as a option? Well here is the answer to your problem. This program will grab onto anything sent out of a line printer port as long as the program uses the standard BIOS INT 17h call. This version works with Shift-PrtSc or Ctrl-PrtSc but does not work with the DOS TYPE command. This program intercepts the BIOS interrupt 17h, the line printer interrupt. It will redirect the output of LPT1, LPT2, or LPT3 to a disk file. All three redirections may be active at the same time. This version of LPTx counts on the PC having some "free time" in order to write the data to disk. The program gathers data into a large buffer and during timer interrupts and keyboard idle periods, it writes it to disk. DOS must not be in its critical section for the write to take place. LPTx does not work with the DOS TYPE apparently because the critical section flag is always set when the timer interrupts occur. It should work with most user programs since the critical section flag is not set in user programs and therefore will not be set when timer interrupts occur. Look at the Assembly Language Source which you should have received with this documentation file. If you would like the other versions of LPTx, I will be happy to send them to you. Just send me a formatted 360K DSDD floppy (no DOS on diskette) along with a post-paid, self-addressed floppy mailer. I will send you all current versions that are active. If you received this disk directly from me, all of the different versions are already on the diskette. LPTx requires DOS 2.0 or later. It has been tested on version 3.1 of DOS as well. Calling sequence: lptx [?] [-x] [-l] [-i] {-1,-2,-3} {-c -o <d:[pathname]filename>} where -1 means redirect LPT1, -2 means redirect LPT2, -3 means redirect LPT3 This option must appear first -o means start the redirection to file specified. If redirection is already in progress for the selected line printer, the old file will be closed first. (If you do not specify -o but you do specify a line printer, LPTx will use either the last file name that you gave when you loaded LPTx or will use the file named LPTXy.LST which it will create in the root directory on the default drive - where y is 1, 2, or 3.) It is not necessary that you specify the complete path name for the file. LPTx will create the file in the default directory if you don't specify a directory. LPTx will always be able to find the file because it saves the complete path. -c means close the file and send all further output directly to the line printer. If neither the -o or the -c option is specified, LPTx just displays the program status. -? displays a short help screen. -x tells LPTx to ignore the DOS Critical Section Flag. Use this option only with great care. LPTx may do unusual things if the flag is ignored. -l tells LPTx to strip linefeed characters from the data as it is being redirected. -i removes LPTx from the interrupt chain. This effectively inactivates the program. The memory which it occupies is not freed. note: -1, -2, and -3 are mutually exclusive -o and -c are mutually exclusive examples: lptx Displays the program status lptx ? Displays a HELP screen lptx -1 redirects LPT1 output to file named LPTX1.LST in the root directory on the default drive or the last named file. lptx -o a:\able.xxx redirects LPT1 output to file named or a:\able.xxx. Any open redirection lptx a:\able.xxx disk file for LPT1 is closed. lptx -2 b:xx.lst redirects LPT2 output to file named XX.LST in the default directory on drive B:. Any open redirection disk file for LPT2 is closed. lptx -3 d:\ab\cd\file.lst redirects LPT3 output to the file named file.lst in the directory ab\cd on drive d:. lptx -c closes any disk files open for LPT1 and sends or the output back to the line printer lptx -1 -c If no redirection is taking place to LPT1, this is a NOP. LPT2 and LPT3 are not affected. lptx -2 -c closes any disk file open for LPT2 and sends the output back to line printer. if no redirection is taking place to LPT2, this is a NOP. LPT1 and LPT3 are not affected. By redirecting LPT2 or LPT3 to a disk file, you can in effect have 2 or 3 printers on your system. LPT1 can be your physical printer and you can have LPT2 output going to disk. When you redirect LPT2 or LPT3, LPT1 works normally. If you are redirecting to a diskette file, do not remove the diskette once the redirection starts. I recommend redirecting to a hard disk or a RAM disk. If LPTx encounters any kind of error during the redirection, it terminates operation and sends output back to the line printer. It does not display anything but beeps the speaker. Four beeps indicates a DOS disk access error. Two beeps indicates an internal buffer overflow error. This prevents your currently running program from possibly getting destroyed. An error with LPT1 redirection does not shut down LPT2 or LPT3 redirection. LPTx captures the int 17h interrupt vector. Problems may occur with print spoolers which also take over the int 17h vector. You can be sure that LPTx works correctly by running LPTx before you run your print spooler. LPTx will be transparent to the print spooler but your print spooler may not be transparent to LPTx. LPTx works fine with IBM's PRINT command. LPTx also captures the int 24h critical error interrupt vector. This is done only for the period that LPTx is using the disk. This prevents the generation of funny error messages in the middle of other programs that you may be running. (LPTx just beeps 4 times and clears itself out of way if a disk error occurs). This version of LPTx can redirect all three printers to three different files with all 3 active at the same time. LPTx worked correctly when I tested it with: 1. dBaseII, 2. the ARC utility with the "p" option and output redirected to prn, 3. shift PrtSc, 4. DOS PRINT utility, 5. Lotus 123, 6. dir > prn, LPTx did not work with: 1. The DOS TYPE command, 2. Version 6.00 of LPTx uses about 20K of memory for the resident data buffers and interrupt handler. This is greater than the previous versions of LPTx because I made the disk buffers larger. If you modify or find any bugs in this program, I would appreciate it if you would drop me a line with the changes. Use the address above. Updates and new versions of this program can be found on the RBBS at 619-741-3412.
ecctp@warwick.ac.uk (Dr J A K Cave) (09/12/89)
Code will be posted in a week if no copyright problems surface. Please advise. PRNDSK Version 1.00 A Printer-To-Disk Redirector INTRODUCTION ------------ PRNDSK is a utility that redirects output intended for a printer or communications port and sends it to a disk file or other device. It is intended to make it easy to capture disk copies of printed output and screen dumps. It can also be used to discard printer output by redirecting it to the NUL device, and you can even use disk files as "virtual printers" if your computer does not have the printer ports you need. PRNDSK is written for the IBM PC and closely compatible computers, running MS-DOS version 2.00 or later. Although it tries hard to be reliable, it is very likely that there are computers and programs with which it will not work. If you have problems, or suggestions for improvements, contact the author: David H. Rifkind 3993 N. Campbell Ave., #53 Tucson, Arizona 85719 BIXMail: drifkind PRNDSK and this document are copyright 1987. SYNOPSIS -------- There are three basic formats for the PRNDSK command: 1. PRNDSK [/C][/F] Displays information about devices currently being redirected, or closes all files (/C), or flushes them to disk (/F) while leaving them open. 2. PRNDSK device [/C][/F][/N][/T] Displays redirection information about the specified device, or closes its redirection file (/C), flushes it to disk (/F), or sets or clears the transparency mode (/N, /T). 3. PRNDSK device=filespec [/A][/T] Begins redirecting a device to the file specified. The /A switch is used to append to an already existing file, and /T to set the transparent redirection mode. "Device" may be one of the following names: LPT1 through LPT3 Printer ports 1 to 3 COM1 or COM2 Serial ports 1 and 2 PRN Same as LPT1 AUX Same as COM1 "Filespec" may be any unambiguous file specification. Legal examples include: PRINTER.TXT A:COM1.TXT ..\LISTING C:\DEVEL\PRINTER.TXT NUL REDIRECTING OUTPUT ----------- ------ To direct output intended for a printer or serial port to a file, enter the following command: PRNDSK device=filespec "Device" should be replaced by the name of an output device: LPT1, LPT2, LPT3, COM1, COM2, PRN or AUX. "Filespec" is replaced by the name of a file to receive the output. Here is an example of a legal command: PRNDSK PRN=PRINTER.TXT This will result in output to the printer being sent instead to the file PRINTER.TXT in the current drive and directory. A drive and path name may also be included in the filespec: PRNDSK COM1=C:\FILES\LOGFILE.COM In fact, "filespec" may be any MS-DOS file or device name, including CON, NUL, or even a printer or serial port! If output is redirected to a serial port or printer port, it is not further redirected. To make this clear (or at least clearer): PRNDSK PRN=COM1 PRNDSK COM1=COMM.TXT In this example, output sent to the PRN device will go to serial port number 1; it will NOT go to the file COMM.TXT. There are two switches which may be included with this form of the PRNDSK command. The /A switch: PRNDSK device=filespec/A causes data to be appended to the output file. If the /A switch is not included, the file will be erased before beginning output. The /T switch: PRNDSK device=filespec/T results in transparent output--characters output will go to both the redirection file AND to the specified device. This allows you to make both a soft and a hard copy at the same time. Once redirection to a file is begun, the disk containing that file should not be removed. Close the file (see OUTPUT CONTROL) first. OUTPUT CONTROL ------ ------- To close an output file and terminate redirection for that device, use this command: PRNDSK device/C or PRNDSK/C The second version closes all files and terminates all redirection. PRNDSK also lets you flush an output file, that is, update the file directory information on the disk without closing it. Make whatever use of this that you can: PRNDSK device/F or PRNDSK/F DEVICE STATUS ------ ------ To keep track of what devices you have redirected, PRNDSK will show you the status of each device it handles. To find out to what file a given device is being directed, enter: PRNDSK device For example: PRNDSK PRN The reply might be: LPT1=C:\FILES\PRINTER.TXT If the device is set for transparent redirection, the file name will be followed by a "/T": LPT1=C:\FILES\PRINTER.TXT/T If redirection to the file has been stopped due to a DOS error, the error message will be shown after the file name: LPT1=C:\NONESUCH\PRINTER.TXT Path not found Finally, if the device in question is not being redirected, there will be no reply. To list all devices being redirected, type: PRNDSK Note: the way the filename is reported varies slightly with different versions of MS-DOS. In DOS 2.xx, the filename is reported exactly as you entered it. In DOS 3.xx, the complete unambiguous filespec is given. PRNDSK PRN=..\FILES\PRINTER.TXT DOS 2.xx: LPT1=..\FILES\PRINTER.TXT DOS 3.xx: LPT1=C:\SUBDIR\FILES\PRINTER.TXT CHANGING MODES -------- ----- A redirected device may be switched into and out of the transparent mode using one of the following commands: PRNDSK device/T to set transparent mode PRNDSK device/N to clear transparent mode "/N" is a mnemonic for "not transparent", and deserves an award as one of the least mnemonic mnemonics ever. ERROR HANDLING ----- -------- If any DOS error occurs while PRNDSK is trying to write to a file, the associated device will become "inactive". Attempts to write to the device will generate printer I/O errors (for the printer ports) or timeout errors (for the serial ports). The device will remain inactive until it is closed (by PRNDSK/C). COMPATIBILITY ------------- PRNDSK intercepts the IBM PC's BIOS INT 14h and INT 17h vectors (the serial and printer service interrupts). It may not work correctly with other programs which also take over those vectors. In most cases, PRNDSK will work with printer buffer software if it is loaded AFTER that software. Due to the design of the IBM PC's ROM BIOS, a great number of programs that use the serial ports will not work with PRNDSK. However, if your serial ports are being used for simple output devices such as printers or plotters, it should work. Don't be surprised, though, if your modem attached to COM2 prevents your using PRNDSK with the printer attached to COM1. PECULIARITIES ------------- "Peculiarity" is the word we have chosen to describe some of the stranger aspects of PRNDSK's operation. The word "feature" might also be used. Use of the term "bug" is frowned upon. In order to work correctly with DOS, PRNDSK keeps track of calls to the various DOS services. This allows it to decide when it is safe to write to the disk, and when to wait for a better time. It is not always possible to make this decision correctly, so PRNDSK adopts a conservative approach: it never writes to the disk unless it is quite sure that it is safe. Under some circumstances, it may be impossible to write to the disk for a considerable period of time. When this happens, PRNDSK can lose some characters which were sent to the printer. This is rare, and may happen with some programs and not with others. One simple example which will demonstrate this is: COPY somefile PRN where "somefile" is more than about 2K bytes long. There is no apparent good solution for this problem. Another peculiarity has to do with opening files. Under some circumstances, this sequence of commands: CHDIR \FIRST PRNDSK PRN=PRINTER.TXT CHDIR \SECOND will result in PRINTER.TXT appearing in directory SECOND instead of FIRST. This will happen only (1) when using DOS 2.xx and (2) the first time that PRNDSK is run (that is, if PRNDSK is already resident in memory, this will not happen). If this behavior causes a problem, you can follow the first PRNDSK command with: PRNDSK PRN/F which will ensure that the file ends up in the correct directory. PROGRAM NOTES ------- ----- This is the first publicly released version of PRNDSK. There are other programs that do about the same thing. I hope that PRNDSK is more reliable and more functional than the others. I also hope that you find it useful. This first version is fairly rough in several ways. Since it uses a 2K buffer for each of five devices, over 8K of memory is wasted if only one is being redirected. There are also all those darned "peculiarities" (see above). If there is enough interest in PRNDSK, I might get ambitious and make improvements. This is copyrighted material. No fee is charged for its use. You may reproduce and distribute it as you see fit, but please do not distribute modified or incomplete copies. 28 Feb 1987
root@cca.ucsf.edu (Systems Staff) (09/13/89)
In article <238@orchid.warwick.ac.uk>, ecctp@warwick.ac.uk (Dr J A K Cave) writes: > Code will be posted in a week if no copyright problems surface. Please > advise. > ... > > This is copyrighted material. No fee is charged for its use. > You may reproduce and distribute it as you see fit, but please do > not distribute modified or incomplete copies. In this case the release is explicit so the only question is its authenticity. But the announcement at the beginning is a bit disturbing. Even though its author may understand correctly, the way it is expressed may be misleading to some. If there is doubt about the status of the material it is the responsibility of the person proposing to distribute it to obtain explicit permission from the copyright holder. It is not enough to make a statement of your intentions, even publicly, and take silence as permission. Whether you could make such an assumption if you had directly notified the copyright holder is a question that only legal counsel could advise you on and the question probably has many complicating factors. Thos Sumner Internet: thos@cca.ucsf.edu (The I.G.) UUCP: ...ucbvax!ucsfcgl!cca.ucsf!thos BITNET: thos@ucsfcca U.S. Mail: Thos Sumner, Computer Center, Rm U-76, UCSF San Francisco, CA 94143-0704 USA In assumption lies litigation. #include <disclaimer.std>
ecctp@warwick.ac.uk (Dr J A K Cave) (09/13/89)
Thanks to all for advice re: posting other folk's code. It would take a while for postings to make it through the backlog on c.b.i.p. anyhow, so I won't bother. I guess the best thing to do is contact the authors listed in the documentation. It's a bit hard for me, being overseas and all. Sorry to raise anyone's hopes unnecessarily. A couple of hints, though: 1) there is an LPT utility included free with Harvard Graphics; 2) any program run within MS Windows can be ported to a file by declaring the file to be an output port in WIN.INI. This will work with e.g. 123 if you declare a postscript printer when setting up and redefine LPT1 before using PrintGraph. 3) there is one MAJOR drawback that might not be evident if you've only used hardpronter connections before; the PS files tend to be on the immense side (like 3-700K for a single graph), so I hope you have lots of storage space, lots of patience, and/or a good background upload/print program. Once again, sorry for the blundering. Next time I'll know better.