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...
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.


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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can we display time in 12 hr format using batch file ? 2 57
ticket bloat 3 70
Scan to Gmail emails never arrive 12 46
DNS/WINS in a domain 10 40
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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