Link to home
Start Free TrialLog in
Avatar of 3vz713

asked on

Printing from DOS progam to screen escape sequences in telnet session

Here's the issue I've been struggling to solve: We've moved software from physical DOS machines to a Georgia SoftWorks telnet server running on Windows 2003 to run DOS programs remotely. It supports passthrough printing (print escape codes sent directly to the screen) and the logon script for the user includes the variable that specifies passthrough printing for the client.

The problem? The programs don't support passthrough printing! Yes, I could map LPT1 to local clients however the terminals are going to be accessed from remote locations that do not have print servers or other means of connecting the remote printer to the Windows server through net use.

Yes - there are easy ways of solving this, like using the native Georgia Softworks client to support printing. However, we MUST use Ericom PowerTerm (which interprets escape codes from the host) for terminal emulation and using the native client isn't an acceptable solution as it is missing many of the features we require.

For example, I've been trying to print from WordPerfect 6.2 and the print job disappears instantly after printing. There are no options to configure screen-based output.
From edit at the command prompt it comes up with an error box that it cannot open LPT1 when attempting to print.

Here's what I'm thinking needs to be done: Print to file, or redirect LPT1 to a file and have print jobs saved for later printing. A program or batch file (perhaps incorporating external software) needs to be written which will output the saved print files to the remote terminal using the proper escape codes, thereby allowing PowerTerm to handle printing. Another issue is that the program must run in the foreground, of course, so that PowerTerm can receive the escape codes. Having the user manually exit the current program and launch the print program is no big deal (and I'm pretty sure that's the only way this can be done). It's possible we might need some unix-based commands from the Subsystem for Unix applications to actually pass escape sequences properly rather than the built-in "echo" in Windows.

Any help in putting together this program is greatly appreciated, thanks a lot!
Avatar of n2fc
Flag of United States of America image

Are you trying to print to an actual printer from within the telnet session?

Try starting the DOS session with a "net use" command to access the printer on the server...


Example: net use LPT1 \\{hostname}\{printername}

Sorry... Just re-read your problem statement & see you state you can't use "net use"...

Still confused by what you are trying to print on!

Have you looked at this software?

It MIGHT help...   I think they have a free trial, so it's worth a shot to test in your system!
Avatar of 3vz713


See that's the problem, I don't have a printer to print on. At least nothing that can be mapped over a network share like that as the printers are not accessible to the server hosting the terminal session.

I guess what I'm trying to do is print to screen - literally. I'm trying to take that spooled print file and have it directly output its information to the telnet session's screen. The only thing that is supposed to direct whatever is dumped to the screen to the printer is the escape code \033[5i preceding the printed text. The limitation when using Windows is having Windows actually interpret that escape code as an escape code and not just simple text that gets shown on the screen when you try to use the echo command in windows. In unix you can go "echo -e \n\033[5i [insert print job] \r\n\033[4i" and those characters would be invisible on the terminal screen but the printer would print that text.

I'm sure this can be done and I'm fairly good with programming batch files but I've never come across this kind of issue before and there isn't much info on exactly how to enter the escape sequences into a command so that they are interpreted properly in Windows.

This topic is fairly helpful in understanding what I'm trying to do:

In my case, Windows does not have a virtual folder or anything to print like that like Unix does.
In the logon script, try using "net use" to map LPT1 to CON:

That should route your LPT1 output back to the      console...
I wonder if you could simply just print it to a file and use a batch file to move the file elsewhere to print it to a physical printer. I assuming you would have a delay, but it should still work.

I am not familiar with the DOS emulator in which you are running through.
I use DOSBox internally here to virtualize dos, but i output prints to a text file then use a batch script to move them to a network share, and print them to a network printer. It's not hugely fast, but it does seem to work..

If you did >c:\filename.txt instead of your print command it should write it local, unless you have an emulated filesystem. then you may have some issues doing this..
but then used a batch script to move the said files to a mapped drive off the 2k3 box, you should be able to then print them from that mapped location..
Avatar of 3vz713


I do appreciate the suggestions but I think I should make it more clear, the print job MUST go to the screen in its final stages (i.e. visible to the terminal emulator (PowerTerm) but showing a blank screen for the user printing since the escape codes define what the user sees on the screen) for this to work - if Windows shares were accessible/possible then I would have no problem just printing directly to the printer, know what I mean?

I tried net use LPT1 from above but the problem is there is no "console" number, it is simply referred to as a process ID. There is no support for serial communications in the program, in fact there is no way of even knowing that you're running on a telnet session from the terminal, sort of like running cmd there is no console number, programs think they're running from a single user system.

The software runs directly out of Windows 2003's NTVDM with a few tweak programs (TameDOS) to ensure the DOS programs behave themselves but otherwise the filesystem is directly accessible to the user through the shell.

I'm thinking another option would be using a PowerShell script but that I'm completely unfamiliar with and still don't know if even that will let me send an escape character to the screen to cause a print job.
I meant to literally use the command:
net use LPT1 CON:

Open in new window

... but apparently that is not a valid option...


Another program you might try to capture the output in DOS for subsequent streaming back to the console is here:

We'll keep on looking for things to try as long as you agree to try them and report results back!
Avatar of 3vz713


n2fc, when I try that command exactly as typed, I get "System error 67, the network name cannot be found". The first time I tried it I did type it exactly as shown but I should have stated the full command rather than jut "net use LPT1" in my comment as it seemed like that's all I was typing in.

Now I think that it's possible Printfil will work as long as it can output to the screen - it supports sending escape sequences to the "printer" so it should work when sending escape sequences to the screen. It mentions telnet support but gives an example of it functioning similarly to just typing "net use ..."; in other words it will only print to mapped printers and not to the screen in that fashion.

I'll give it a try later tonight and see if it works.
Avatar of 3vz713

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.