Operating System - HP-UX
1833789 Members
2696 Online
110063 Solutions
New Discussion

a2ps does not interpret ^M as carriage return

 
SOLVED
Go to solution
TCEQ UNIX
Advisor

a2ps does not interpret ^M as carriage return

if lp is used when printing insead of ^M, it underlines words, but if I use a2ps to print the same file it prints ^M and word. I have to use a2ps in order to print report correctly. Any suggestion?
He who does not slow down at the sight of a police car is usually parked.
10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor

Re: a2ps does not interpret ^M as carriage return

This is a little strange, ^M should simply be a carriage return - it should not trigger underlining. There may be some ESC sequences that you are not seeing. You should probably examine the input file with od to know for sure.

In any event, what you can do is send the output through tr before piping to a2ps
e.g

tr -d "\015" < infile | a2ps
If it ain't broke, I can fix that.
TCEQ UNIX
Advisor

Re: a2ps does not interpret ^M as carriage return

Thank you for the reply, but it is not working. i have cut/paster a portion of the file. If I use "lp -dprinter file" it prints as MASTER ALPHA ... and underlines them, if I print using a2ps it prints in the same format as below. Have any suggestions.
+++++++++++++++++++++++++++++++++
^LPROPHECY DEBTORS TX COMM ON ENVIRONMENTAL QUAL PRINTED ON 02OCT02 10
:58AM PAGE 1
AGED ACCOUNT DETAILED REPORT DTLD AGED ACCTS RPT(ANAL3) AS AT OCT0
2,02 FOR 23/02

======================================================================================================================
==============
______ _____ _______ _______ _______
__ ____^MMASTER ALPHA ADDRESS ADDRESS ADDRES
S AD POST
He who does not slow down at the sight of a police car is usually parked.
Dave Chamberlin
Trusted Contributor

Re: a2ps does not interpret ^M as carriage return

Is this file from a PC? If so did you run ux2dos on the file? This will change the carriage returns to be correct for hpux. You should not have ^M characters in your file unless it came from a PC.
TCEQ UNIX
Advisor

Re: a2ps does not interpret ^M as carriage return

thanks for the reply. This is a PC report which needs to be printed through UNIX print Queue. ux2dos removes the ^M, but does not force carriage control. The word immediately followed by ^M should start printing from the same line, underling MASTER. Do you think by replacing ^M by "carriage return" will work. What is equivalent to carriage return in UNIX ?
He who does not slow down at the sight of a police car is usually parked.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: a2ps does not interpret ^M as carriage return

Your original posting was very unclear; however, now that you posted some of your input stream, it's quite obvious what is happening.

You first print some text then issue a CR and then print underscore characters on the same line. This works fine on ASCII print jobs but a2ps simply outputs these as two separate strings. Cntl-M (dec 13 octal 15) is an ASCII CR. You are somehow expecting a2ps to understand this sequence and it doesn't have a clue.


If it ain't broke, I can fix that.
TCEQ UNIX
Advisor

Re: a2ps does not interpret ^M as carriage return

I have to use postscript print queue to print report otherwise it does not page break at the right place because line setting on the network printer is different than the page break on the report, which is hard coded on the report. Do you have any suggestions that will fulfill both requirement - CR and page break. Thank you.
He who does not slow down at the sight of a police car is usually parked.
Sandip Ghosh
Honored Contributor

Re: a2ps does not interpret ^M as carriage return

You can try dos2ux on your Unix Box. First bring the repot to unix box. Then run dos2ux on that.

Sandip
Good Luck!!!
TCEQ UNIX
Advisor

Re: a2ps does not interpret ^M as carriage return

dos2ux only takes ^M out but does convert the report to right format - CR does not return, so it fails to underline "MASTER"....
He who does not slow down at the sight of a police car is usually parked.
A. Clay Stephenson
Acclaimed Contributor

Re: a2ps does not interpret ^M as carriage return

If all you need to do is control page length then you can pipe the input file through pr. You can use the -l argument to specify page length and -t to supress page headers/trailers. Whenever a FF is encountered, it will be expanded to the appropriate number of LF's.

Plan B. Most printer interface files have options to set page length. Add the appropriate -o argument to your lp command.

Plan C. Create an awk or Perl script to act as a filter for your input file. This is quite easy to do.


If it ain't broke, I can fix that.
TCEQ UNIX
Advisor

Re: a2ps does not interpret ^M as carriage return

since ^L is hard-coded on the report, and printer setting, line=60 (which is not possible to change due to print jobs for other applications), I was not able to make -o line option work on landscape mode. How does the code look on perl or awk ? can you please write the code . Thanks.
He who does not slow down at the sight of a police car is usually parked.