Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a question and I hope somebody has an answer. I am using telnet from my Windows PC (God help me) into our unix box (running Sun Solaris). I wrote a program in Perl on the unix platform and want to know if there is a way to direct the print output back to the local printer on the Windows platform (LPT1). Am I spitting into the wind here or is it possible? Any and all help is greatly appreciated.

Replies are listed 'Best First'.
Re: Printing to Local Windows Printer
by sgifford (Prior) on Aug 28, 2003 at 15:20 UTC
    This is the shell script we use for this. Your term program has to support it.
    #!/bin/sh # Send VT100 sequence for start print /usr/bin/echo E[5i\\c | tr E \\033 #send the file cat $1 # Send a form-feed /usr/bin/echo F\\c | tr F \\14 # Send VT100 sequence for end print /usr/bin/echo E[4i\\c | tr E \\033
Re: Printing to Local Windows Printer
by MidLifeXis (Monsignor) on Aug 28, 2003 at 13:29 UTC

    Depends on your telnet client. Some clients allow a terminal escape code that diverts output to a printer or file. However, it has been so long since I have had a need to do this I am quite rusty.

    So you would do....

    startprint; cat file; stopprint

    ... where startprint and stopprint generate the appropriate codes. Of course, this is assuming that file is a text file.

      There is indeed a printer output option in my telnet client. What I am doing is opening a printer port in unix and printing to a specific printer. Here is the initial line: open (LPR,"|lp -dpclaser -s"); where "pclaser" is the printer name. We also have some "C" programs running here. You can select the "local" option in these programs and the output will be to the printer connected to the telnet client.

        If you want to / are able to set up a print queue for your local printer, there are lpd daemons available for win32.

        However, the way that programs print to the local printer without setting up a print queue is to use the terminal's escape sequences to divert output on the local side (your telnet client) to the printer. See my above post.