Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script with telnet codes

Status
Not open for further replies.

pfildes

Programmer
Jun 17, 2004
54
GB
I have some UNIX software which runs in a windows environment via some Telnet software. This UNIX software calls a script which passes a PCL file to a users windows default printer using the following source code;

Code:
(echo "\0033\0133\0065\0151\c"
  cat $spoolfile
  echo "\0033\0133\0064\0151\c"
  ) > $TTY

This worked fine up until we introduced a Windows bitmap into the PCL file.

Can anybody please explain the codes listed above and maybe tell me what I'm doing wrong? [ponder]
 
Hello,

maybe I completely misunderstood what you are doing. But here are my thoughts about it:

man echo will tell you that the numbers in \0xxx are the octal equivalent of the characters to be echoed. This way often is choosen when the characters cannot be typed in easily.
man ascii will tell you what these characters actually are, e.g. you will see that 033 is the escape character, aka Esc. And a sequence of characters beginning with an escape is called an escape sequence. As you probably know, they are used to change the behaviour of hardware like printers and terminals. HP's Printer Control Language PCL is in essence made up from quite a lot of them.

Then I suppose the $spoolfile in your script is the PCL file you are talking about.
And your $TTY seems to be a serial port, aka tty, on your Unix box. I suppose the printer is connected to it. I can't see how Windows and Telnet come in though.

So you send your PCL file to your printer, enclosed between two additional escape sequences.
This may well work, as long as your file is in a version of PCL that your printer is able to understand.

Now you introduced a Windows bitmap into the PCL file. (How did you do that, btw?)
We may assume that in this bitmap file there are all kinds of bytes, including quite a number of Esc, and therefore there will be a lot of randomly choosen escape sequences. Some of them have no meaning, and so will cause an error, if anything at all. But others will randomly change your printer settings.
Anything else but a complete havoc would be a huge surprise.

You cannot print a bitmap that way, imho.
May I ask why you are trying to reinvent the wheel?
Why don't you use the Unix or Windows spool system?

hope this helps a bit.

 
Thanks for your reply.

The bitmap was actually encoded in the PCL file by a 3rd party application whose supplier stated that they were unable to help with the printing issue. In the end we dropped the added bitmap as we could not pursue the problem any further.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top