Solved

Printing in Linux

Posted on 1998-10-11
5
223 Views
Last Modified: 2010-03-18
I have installed RetHat v5.1, I am attempting to configure a local printer.  I believe that I have managed to do so because I can 'cat' text files to /dev/lp1 and 'lpr -PBenFranklin' files (BenFranklin is the printer name) and they print on the printer.  Now, I want to be able to be in Netscape, StarOffice, or some other word processing software (WYSIWYG type) and print to the printer.  I am aware that I most likely will need GhostScript, and it is installed, but I can't seem to get it to print to the printer...
0
Comment
Question by:jhasz
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:marcelofr
ID: 1587157
lp command will try to print to printer "lp" by default. If you want to change it, just set PRINTER environment variable to the desired printer. Add the following lines to you /etc/profile (for a global definition) or your ~/.bash_profile (it could be your startx script or whereever you think is better):

PRINTER=BenFranklin
export PRINTER

This should do the trick. Anyway most applications support configuring what printer you want ie.: netscape ask you for a "printer command" where you can put "lpr -PBenFranklin"...

Good luck
0
 

Author Comment

by:jhasz
ID: 1587158
This fails to address the actual question.  Simply setting the PRINTER environment variable will not allow printing a PS based output to my BJC printer.  All the helps do is say, "you need GhostScript" and here are the switches to pass it.  But how does GhostScript get invoked?  What causes the program producing the output to redirect that output to GhostScript? or how does GhostScript grab the output from that program and route it through itself before allowing the job to continue on to the output?  I need to be able to print a presentation quality document on the printer, not just a plain text doc.  Any other ideas?
0
 
LVL 3

Expert Comment

by:marcelofr
ID: 1587159
Aren't you using printtool to create the printer? aren't you using the redhat print filter to handle printings?
Ghostcript comes with RH51 and all the funny scripts you need...
0
 
LVL 1

Accepted Solution

by:
talwyn earned 50 total points
ID: 1587160
Yes you need Ghostscript.  It is invoked via a print filter in your /etc/printcap file.  Below are the files I use to invoke it. Your script will differ in that you will be using an actual printer instead of a samba printer.

  here is an excerpt of mine:
/etc/printcap
qms|lp2:lp=:rm=dewey.texmicro.com:rp=lp:sd=/usr/spool/lpd/qms:sh:if=/usr/spool/lpd/qms/input_file:lf=/usr/spool/lpd/qms/errs
#
smbp|lp:lp=/dev/null:sd=/usr/spool/lpd/smb:mx#0:sh:if=/usr/spool/lpd/smb/input_filter
#
smbw|lp4:lp=/dev/null:sd=/usr/spool/lpd/smb:mx#0:sh:if=/usr/spool/lpd/smb/input_filter4
#
smbps|lp3:lp=/dev/null:sd=/usr/spool/lpd/smb:mx#0:sh:if=/usr/spool/lpd/smb/input_filter2


Note Smbps ... this is my postscript driver for an smbprinter.

here is the script of  /usr/spool/lpd/smb/input_filter2

#!/bin/bash
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
#echo  Running Lp filter now
#echo --------------------------------------------- >> /tmp/testlp.out
#date                                               >> /tmp/testlp.out
#echo --------------------------------------------- >> /tmp/testlp.out
#cat                                                >>/tmp/testlp.out
cat |/usr/bin/gs -q -sDEVICE=laserjet -r300 -sPAPERSIZE=letter  -sOutputFile=- - |/usr/spool/lpd/smb/input_filter  
#(echo translate
# echo print -
# cat )| /usr/bin/smbclient \\\\tech_serv2\\laserjet_4v  " "  -N -USteven@Mirage -P >> /tmp/printlog


and for completeness here is the filter /usr/spool/lpd/smb/input_filter  which is invoked after ghostscript:

#!/bin/sh
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
#echo  Running Lp filter now
#echo --------------------------------------------- >> /tmp/testlp.out
#date                                               >> /tmp/testlp.out
#echo --------------------------------------------- >> /tmp/testlp.out
#cat                                                >>/tmp/testlp.out
(echo translate
 echo print -
 cat   )| /usr/bin/smbclient \\\\tech_serv2\\laserjet_4v  " " -UMirage -N -P >> /tmp/printlog

0
 

Author Comment

by:jhasz
ID: 1587161
Answer appears to give me the information which I seek, I'll give it a try.  which lines I needed to pay attention to in the scripts tho, are a little hazy, so this may take me some time to figure out.  I am assuming (and we all know what that does) that it's the ones with gs in them!  and maybe the ones right before and right after.

Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now