Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!pumpkin.pangea.ca!www.nntp.primenet.com!nntp.primenet.com!howland.erols.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!nntp-xfer-1.csn.net!news.acsu.buffalo.edu!dsinc!newsfeed.pitt.edu!bb3.andrew.cmu.edu!cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!mozo.cc.purdue.edu!hopf.math.purdue.edu!wilker From: wilker@hopf.math.purdue.edu (Clarence Wilkerson) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Jetdirect via *BSD Date: 14 Dec 1996 11:47:26 GMT Organization: "Purdue University Department of Mathematics" Lines: 90 Message-ID: <58u44e$o5o@mozo.cc.purdue.edu> References: <nGogtM2@quack.kfu.com> <58srlf$jti@uriah.heep.sax.de> Reply-To: wilker@math.purdue.edu NNTP-Posting-Host: hopf.math.purdue.edu To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:32593 The JetDirects I have for LJ II, LJ III do not support internally the LPD protocol. You have to set up a socket connection to port 9100 for these. Here's a perl script that I use under Sunos: ( I`ve lost the author -- not me ) #!/usr/bin/perl # # Hewlett Packard (HP) JetDirect lpd "if" driver for Linux. # # You'll need a copy of this script for each jetdirect printer, because # there's no way to pass parameters to "if" drivers. This driver # assumes that the JetDirect printer understands postscript. # See the "Linux Printing HOWTO Guide" for details on how to # integrate ghostscript into this driver. # # The /etc/printcap entry should look something like: # lp|PostScript|postscript|ps:\ # :lp=/dev/null:sh:sd=/var/spool/lpd/:\ # :lf=/var/spool/lpd/lpd.log:if=/etc/bigoneif: # Don't forget to create the spool directory and log file. # # /etc/services should have an entry like: # hpjetdirect 9100/tcp # CWW added ENV -- wouldn't work from lpd without it #Set PATH $ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin"; # CONFIGURATION $printer = 'ljet'; # Internet address of the JetDirect printer $service = 'hpjetdirect'; # Name of service in /etc/services # How to talk to BSD sockets from perl. $AF_INET = 2; $SOCK_STREAM = 1; $structSockAddr = 'S n a4 x8'; # Get protocol and port (($proto) = (getprotobyname('tcp'))[2]) || &hardErr("getprotobyname('tcp'): $!"); # Try to get the service, but if that isn't available try 9100. # (($port) = (getservbyname($service, $proto))[2]) || $port = 9100; # Get host addresses chop($host = `hostname`); $host || &hardErr('unable to get hostname'); (($hostAddr) = (gethostbyname($host))[4]) || &hardErr("gethostbyname($host): $!"); (($printerAddr) = (gethostbyname($printer))[4]) || &hardErr("gethostbyname($printer): $!"); # Open the connection socket(S, $AF_INET, $SOCK_STREAM, $proto) || &softErr("socket(tcp): $!"); bind(S, pack($structSockAddr, $AF_INET, 0, $hostAddr)) || &hardErr("bind($host): $!"); connect(S, pack($structSockAddr, $AF_INET, 9100, $printerAddr)) || &softErr("connect($printer): $!"); # Stuff data substituting unix newlines to msdos newlines while () { $e = sysread(STDIN, $_, 1024); defined($e) || &softErr("read(STDIN): $!"); $e || last; # no filtering in raw version s/\n/\r\n/g; (print S) || &softErr("write(S): $!"); } # All done close(S) || &softErr("close(SOCKET): $!"); exit(0); ################################################################ # softErr(@msg) # Print @msg and terminate. Job will be restarted by lpd. sub softErr { warn("Soft Error: ", @_, "\n"); exit(1); } # softErr # hardErr(@msg) # Print @msg and terminate. Job will NOT be restarted by lpd. sub hardErr { warn("Hard Error: ", @_, "\n"); exit(2); } # hardErr