Can't print certain text files

Kurt Pfeifle k1pfeifle at gmx.net
Sat Jul 28 10:33:33 PDT 2007


Helge Blischke wrote:
> Kurt Pfeifle wrote:
>> James Egan wrote:
>>
>>> Using cups 1.1.23 on an HP-UX 11i server, I was getting this
>>> error when attempting to print someone's .bash_profile:
>>>
>>>   lp -dhp1 .bash_profile
>>>   lp: unable to print file: client-error-document-format-not-supported
>>>
>>>
>>> I found the problem to be an embedded ^U character in this stty command
>>> in the .bash_profile:
>>>
>>>   stty icanon intr \^c echo echoe \$
>>>   ^Iechok erase \^h kill ^U  icrnl isig onlcr opost parenb cs7 $
>>>
>>>
>>>
>>> Here's the error_log entry when attempting to print the .bash_profile:
>>>
>>> E [24/Jul/2007:13:14:13 +0500] print_job: Unsupported format
>>> 'application/octet-stream'!
>>> I [24/Jul/2007:13:14:13 +0500] Hint: Do you have the raw file printing
>>> rules enabled?
>>
>>
>> This ^U character does mislead "auto-typing" operation of CUPS into
>> thinking it is not a text file.
>>
>> Your current mime.types file probably contains this line:
>>
>>    text/plain         txt printable(0,1024)
>>
>> and your ^U char (which is unprintable) probably appears within the
>> first 1024 bytes.
>>
>> You should create your own auto-typing rule and insert it into
>> /etc/cups/mime.types (or better create a "local.types" file there):
>>
>>    text/misctext      txt string(0,##.bash_profile)
>>
>> Then, insert '##.bash_profile' into the very first line of your
>> .bash_profiles, and CUPS will auto-type that file as that specific
>> mime type "text/misctext". (Read the comments in that file to learn
>> more about it --you can add more rules to that line in order to
>> recognize more different files as your new mime type).
>>
>> Next, create your "which conversion filter should be applied to
>> that mime type"-rule. Edit /etc/cups/mime.convs (or better create
>> a "local.convs" file there) and add this line:
>>
>>    text/misctext      application/postscript  33      texttops
>>
>> I've not tested the texttops filter's behavior if it encounters
>> ^U characters. If it does not work, you may want to use another
>> utility (a2ps or enscript come to mind, or even wrap your own
>> script around texttops which first calls something like "recode
>> xyz..abc" to get rid of the ^U (and other weird characters)
>> initially...
>>
>> (This is a very specific recipe -- you can come up with a more
>> elegant and more generic one if you study the mime tying rules a
>> bit that are offered by CUPS)
>>
>>
>>
>>> So, I uncommented these lines in the mime.convs and mime.types files, to
>>> enable the above mime type, and enable the raw file printing rules:
>>>
>>> usr/local/cups/etc/cups> grep octet mime*
>>> mime.convs:# Uncomment the following filter and the
>>> application/octet-stream type mime.convs:#application/octet-stream  
>>> application/vnd.cups-raw 0       -
>>> mime.types:# Uncomment the following type and the
>>> application/octet-stream
>>> mime.types:#application/octet-stream
>>>
>>>
>>> This has the same affect as using the -o raw switch to lp.  Anyway, now
>>> when I print this text file (.bash_profile) the text stair steps like
>>> this:
>>>
>>> line one
>>>                            line two
>>>                                                       line three
>>>
>>>
>>> What can I do now to have this mime type add the CR/LF to each line?
>>> I know I could do something that's really a pain in the ass and write
>>> a filter using sed, or something, but I'm hoping there's a sane
>>> solution.
>>>
>>> -Thanks
>>
>>
>>
> 
> Just for information, CUPS accepts the following "control" codes
> as part of "printable" or "ascii":
> 8 to 13
> 26 and 27,
> i.e. ^H to ^M, ^Z and ESC.
> 
> Helge


Ah,thanks, Helge. Hadn't noted this down yet, but now I did.  :-)

-- 
Kurt Pfeifle
System & Network Printing Consultant ---- Linux/Unix/Windows/Samba/CUPS
Infotec Deutschland GmbH  .....................  Hedelfinger Strasse 58
A RICOH Company  ...........................  D-70327 Stuttgart/Germany




More information about the cups mailing list