Printing from DOS progam to screen escape sequences in telnet session

Posted on 2014-12-15
Last Modified: 2015-01-17
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!
Question by:3vz713
LVL 20

Expert Comment

ID: 40502147
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!

Author Comment

ID: 40502391
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.
LVL 20

Expert Comment

ID: 40502559
In the logon script, try using "net use" to map LPT1 to CON:

That should route your LPT1 output back to the      console...
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Expert Comment

by:Rob G
ID: 40502695
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..

Author Comment

ID: 40503208
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.
LVL 20

Expert Comment

ID: 40503290
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!

Author Comment

ID: 40503324
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.

Accepted Solution

3vz713 earned 0 total points
ID: 40508598
In short, Printfil does not work at all, even just attempting to print spits out garbage no matter what I tried.
I've resorted to saving as a file on a network share, then having Acrobat Distiller convert a postscript file into PDF which works fine.

Now, I've gotten somewhere as far as getting transparent printing to work. It involves using and echoing (esc character)d# (for a Wyse 60) which actually starts a print spool session! That means we're getting somewhere. I haven't been able to get it to print anything yet as the spooler deletes file before anything comes out, but at least the terminal emulator is recognizing the characters.

I haven't had any time at all to work out all the commands yet but I figured I'd throw in a couple commands and see if I get anything and I'm happy to say it's working.
LVL 38

Expert Comment

ID: 40554955
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When I recently replaced my image transfer kit on my office HP color laserjet 5550dn printer, I had a slight problem.  The left bracket that holds the transfer kit got stuck in the upright locked position instead of being at a 45 degree angle facing…
This article was inspired by a question here at Experts Exchange ( The requirements stated in that question are (1) reduce the file size of a large number of…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question