DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD General

NetBSD General Other questions regarding NetBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 14th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default Printer setup question

Hello,

I setup my lpd and printcap for my Brother laser printer (PostScript enabled) on my NetBSD system. The problem I am having is that the filter I wrote for it creates an error when handling shell script files. I think the error comes when the filter tries to process the files commands instead of printing them, but I am unsure of how to fix it.

Here is my /etc/printcap:

Code:
lp|local printer|Brother HL-5240
    :lp=/dev/ulpt0:sd=/var/spool/lpd/lp:lf=/var/log/lpd-errors:\
    :sh:mx#0:if=/usr/pkg/bin/t2ps-filter:

I took the filter straight out of "FreeBSD: The Complete Reference". Here is the t2ps-filter:

Code:
#!/bin/sh
# Check to see if input is PostScript. If not, pass through enscript.

read firstline
firstline=`expr "$firstline" : '\(..\)'`

if [ "$firstchars" = "%!" ]
then
    # PostScript file; pass through $firstline and rest of file
    echo "$firstline" && cat && printf "\004"
    exit 0
else
    # Not PostScript file; use enscript to process
    (echo "$firstline"; cat) | /usr/pkg/bin/enscript -p- \
        && printf "\004"
    exit 0
fi
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #2   (View Single Post)  
Old 15th June 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,165
Default

You don't define the variable ${firstchars}.
Code:
read firstline
firstline=`expr "$firstline" : '\(..\)'`

if [ "$firstchars" = "%!" ]
IMHO that should be
Code:
read firstline
firstchars=`expr "$firstline" : '\(..\)'`

if [ "$firstchars" = "%!" ]
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 16th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

Quote:
Originally Posted by J65nko View Post
You don't define the variable ${firstchars}.
Code:
read firstline
firstline=`expr "$firstline" : '\(..\)'`

if [ "$firstchars" = "%!" ]
IMHO that should be
Code:
read firstline
firstchars=`expr "$firstline" : '\(..\)'`

if [ "$firstchars" = "%!" ]
Ooops. I mistyped - it is
Code:
firstchars=`expr "$firstline" : '\(..\)'`
in the actual file.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #4   (View Single Post)  
Old 16th June 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

What happens when you pipe a doc through that shell script -say $ cat textfile | /usr/pkg/bin/t2ps-filter
Then try cat-ting a postscript file through it - Do you get the desired output?
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
  #5   (View Single Post)  
Old 16th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

Quote:
Originally Posted by robbak View Post
What happens when you pipe a doc through that shell script -say $ cat textfile | /usr/pkg/bin/t2ps-filter
Then try cat-ting a postscript file through it - Do you get the desired output?
I can print regular text files fine. The problem is when I try to print a shell script text file (i.e., try to print the t2ps-filter).
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #6   (View Single Post)  
Old 17th June 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

Ok then, what happens when you cat a shell script through t2ps-filter?$ cat /usr/pkg/bin/t2ps-filter | /usr/pkg/bin/t2ps-filter

It worked for me (at least, the logic did: I don't have /usr/pkg/bin/enscript on FreeBSD). Perhaps the printer is trying to interpret #! as..., no wait, it should be getting postscript. No, I have nothing.

OH, and please don't just tell us that it gives you 'an error'. WHAT ERROR??!??
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.

Last edited by robbak; 17th June 2008 at 01:01 AM.
Reply With Quote
  #7   (View Single Post)  
Old 17th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

I don't know why, but it is working now! It didn't work for me all yesterday, and now it does.


I have one more question on the subject of printing. I am using enscript, which allows for different fonts with the --font=name switch. Which font should I use to get all the characters to print correctly? The default is messing up at least one. In particular, I need "`" to print differently than "'". The default font enscript uses prints both characters identically.

I tried a couple others - Courier12; Courier@12, which is straight from the man pages didn't even print for me - and got nowhere.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)

Last edited by JMJ_coder; 17th June 2008 at 01:09 AM.
Reply With Quote
  #8   (View Single Post)  
Old 17th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

Quote:
Originally Posted by robbak View Post
OH, and please don't just tell us that it gives you 'an error'. WHAT ERROR??!??
The error it was giving was printed on the page from the printer -
Code:
ERROR NAME;
    undefined 
COMMAND; 
    e 
OPERAND STACK;
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #9   (View Single Post)  
Old 17th June 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

Without looking at the data it was sending the printer (which you can get with that cat trick), I couldn't say. It looks like it was barfing over something in enscripts dialect of postscript, to my mind. Your font fiddling may have inadvertently fixed it.

I'm afraid that I don't know enough of the internals of postscript to advise you about fonts. For this basic usage, I'd suspect you are limited to fonts that are embedded in the printer. You may find what fonts are available in the printer's manual.
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
Old 17th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Hello,

Quote:
Originally Posted by robbak View Post
Without looking at the data it was sending the printer (which you can get with that cat trick), I couldn't say. It looks like it was barfing over something in enscripts dialect of postscript, to my mind. Your font fiddling may have inadvertently fixed it.
I didn't start fiddling with fonts until after it started working again. I don't know - it's just one of those things that don't work one moment but then start working again.

Actually, when I started to tweak the fonts, it gave me garbage again - when it even printed. I had to quickly fix the syntax of the script. And actually, I found that if I just use the enscript command instead of trying to incorporate it in the filter it works ten times better. I think I will just alias lpr to enscript.

Quote:
Originally Posted by robbak View Post
I'm afraid that I don't know enough of the internals of postscript to advise you about fonts. For this basic usage, I'd suspect you are limited to fonts that are embedded in the printer. You may find what fonts are available in the printer's manual.
I tried most of the fonts provided by enscript (it uses afm fonts). The only monospaced font appears to be Courier, which doesn't differentiate ` from '. Some of the other fonts do, but they are proportional.

I'll have see if I can scrounge up a better font, because on this setup I am printing a lot of source code - including shell scripts with 's and`s galore. I need a monospaced font that properly prints all of my common characters.


Thanks for the help.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Old 4th November 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

I'm revisiting this question as I setup my laptop to use my printer. I'm half tempted to just install cups and give that a go. But, if I can, I think the base lpr daemon should work fine. I'm either going to print plain text, or I can get non-plain text into a .ps file that can be printed.

I have two questions:

Does the print output of programs such as Firefox (or any browser) and OpenOffice play nice with the lpr daemon? Does it need to be configured with any special options for that?

I had problems with fonts before. Basically the lpr daemon - whatever font it used didn't print every character I needed. Noteably a backtick - ` - was printed as a single quote - ' -. You can imagine the difficulties when I printed out things such as shell scripts. The lpr man page says:

Code:
-[1234]font
             Specifies a font to be mounted on font position i. The daemon
             will construct a .railmag file referencing the font pathname.
...but I find this confusing. What does the [1234] signify - do they all need to be present or do they represent various options; and what is the .railmag file?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Old 5th November 2008
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by JMJ_coder View Post
I'm revisiting this question as I setup my laptop to use my printer. I'm half tempted to just install cups and give that a go.
OK. Please, do not panic. CUPS is for enterprise printing. You do not have 300 printers and 35 different user groups. You do not want that cr*** on your pristine NetBSD machine.

I will give you three suggestions:

1. Note that your Brother HL-5240 (good choice by the way) also speaks Printer Command Language 6. Yes, I do know that theoretically it should be easier just to use as Post Script printer but sometimes the theory and practice are not the same.

2. Also look at Apsfilter. Apsfilter is the simple script which will allow you to install printer. Actually it will just generate proper printcap file for you. It can be used on Post Script Printers as well as the one using drivers from Ghostscript, Gutenprint, and HPIJS.

3. Finally, you can use the same PPD file you are using in CUPS without installing CUPS. Look at the foomatic-filter.

To answer your second question is more tricky. Whether you can use
LPR directly from Firefox or OpenOffice depends on the guy who ported it
to NetBSD. If he kept vanilla configuration than I assume that these applications will expect CUPS. However they will be more than happy to print to post script file which you can pipe to the printer.
You can obviously configure OpenOffice and Firefox to do this automatically.

The advantage of CUPS is that it speaks internet printing protocol IPP unlike LPR which speaks only lpr protocol.
The IPP allows printer to report back to the computer its status. In reality only very expensive printers speak full IPP. PPD files
among other things describe how to fake IPP conversation with the particular printer.

Cheers,
OKO

Last edited by Oko; 5th November 2008 at 06:01 PM.
Reply With Quote
Old 6th November 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Default

Thanks Oko. I did end up installing CUPS, for the simple fact that right now it is the lowest common denominator. I know it will work, and I know how to configure it - and I need to print. As I learn the lpd, which I intend to do, I can then revisit whether CUPS has a place in my userland. Probably over the Christmas break I will re-do my installation, and a lot of these questions will then be re-evaluated.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Printer dont take rights mururoa FreeBSD General 3 5th October 2009 12:54 PM
FBSD 7.1 and Canon LBP-660 Printer Calderon FreeBSD General 8 4th May 2009 07:04 AM
Question regarding wireless setup stealintv FreeBSD General 5 19th September 2008 07:36 PM
IP Printer Setup kjemison FreeBSD General 4 2nd June 2008 02:35 PM
Cups + USB-Printer nihonto OpenBSD Packages and Ports 3 21st May 2008 07:49 PM


All times are GMT. The time now is 11:27 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick